{"id":69123,"date":"2021-08-12T04:10:05","date_gmt":"2021-08-12T08:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/hibernate-a-simple-example-48\/"},"modified":"2021-08-12T04:10:05","modified_gmt":"2021-08-12T08:10:05","slug":"hibernate-a-simple-example-48","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=69123","title":{"rendered":"Hibernate: A simple example #48"},"content":{"rendered":"<p><b>Hibernate: A simple example<\/b><\/p>\n<ol>\n<li> First, you need to create an xml file to specify the database parameters that you are going to use. Database parameters may include: the database driver, user name and password to access the database. <\/li>\n<li> Then you should create a persistent class to represent the database table. One member variable for each table column.Also, you are required to write get and set methods for all of the member variable.<\/li>\n<li> Then you need to write another XML file to map table columns to class variables.<\/li>\n<li> Finally, you need to write the code to make use of the persistent class to store and\/or retrieve data from the table.<\/li>\n<\/ol>\n<p><b>Examples<\/b><\/p>\n<ol>\n<li> XML file (hibernate.cfg.xml) to specify the database parameters:<br \/>\n<blockquote>\n<p>com.mysql.jdbc.Driver      <br \/>jdbc:mysql:\/\/localhost\/hibernatetutorial<br \/>      root<\/p>\n<p>      10<br \/>      true<br \/>      org.hibernate.dialect.MySQLDialect<br \/>      update<br \/>      <!-- Mapping files --><\/p>\n<blockquote>\n<li> I think you know how to write a class with get and set methods<\/li>\n<li> XML file to map table columns to class variables.<br \/>\n<blockquote>\n<p><\/p>\n<blockquote>\n<li> SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();\n<p>session =sessionFactory.openSession();<\/p>\n<p>\/\/Create new instance of Contact and set values in it by reading them from form object, Contact is the persistent class here<\/p>\n<p>System.out.println(&#8220;Inserting Record&#8221;); <br \/>Contact contact = new Contact();<br \/>contact.setFirstName(&#8220;XYZ&#8221;);<br \/>session.flush();<br \/>session.close();<\/p>\n<p><\/li>\n<\/blockquote>\n<\/blockquote>\n<\/li>\n<\/blockquote>\n<\/blockquote>\n<\/li>\n<\/ol>\n<p>From: http:\/\/sitestree.com\/?p=4827<br \/> Categories:48<br \/>Tags:<br \/> Post Data:2011-09-19 21:45:24<\/p>\n<pre><code>    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\"&gt;https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    (Big Data, Cloud, Security, Machine Learning): Courses: &lt;a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"&gt; http:\/\/Training.SitesTree.com&lt;\/a&gt; \n    In Bengali: &lt;a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\"&gt;http:\/\/Bangla.SaLearningSchool.com&lt;\/a&gt;\n    &lt;a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\"&gt;http:\/\/SitesTree.com&lt;\/a&gt;\n    8112223 Canada Inc.\/JustEtc: &lt;a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\"&gt;http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) &lt;\/a&gt;\n    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com'&gt; https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    Medium: &lt;a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"&gt; https:\/\/medium.com\/@SayedAhmedCanada &lt;\/a&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hibernate: A simple example First, you need to create an xml file to specify the database parameters that you are going to use. Database parameters may include: the database driver, user name and password to access the database. Then you should create a persistent class to represent the database table. One member variable for each &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=69123\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-69123","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":67408,"url":"http:\/\/bangla.sitestree.com\/?p=67408","url_meta":{"origin":69123,"position":0},"title":"Hibernate: Key Poins: What is Hibernate: How to develop #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 21, 2021","format":false,"excerpt":"Open source object\/relational mapping tool for Java Provides persistent classes and persistent logic In addition to mapping, provides data query and retrieval facilities Steps: Create a POJO, create an XML mapping file for object to table columns, use Hibernate APIs to load\/store the persistent objects hibernate.cfg.xml file keeps properties such\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65914,"url":"http:\/\/bangla.sitestree.com\/?p=65914","url_meta":{"origin":69123,"position":1},"title":"How to upload data from an excel file to database using servlets? #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 17, 2021","format":false,"excerpt":"Use third party API bundles like jexcelApi. http:\/\/jexcelapi.sourceforge.net\/.---create an XML file to define the structure of your excel file like how many columns, column names, corresponding database table\/class column\/variable name, Create a Java class that can retrieve information from that xml file. You can use XPATH and DOM for the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67364,"url":"http:\/\/bangla.sitestree.com\/?p=67364","url_meta":{"origin":69123,"position":2},"title":"What is Hibernate? #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 20, 2021","format":false,"excerpt":"Why Hibernate? A database is an integral part of many different types of applications. Standalone single-person applications to multi-user distributed business and enterprise applications make extensive use of databases. Many high end technology applications in industries including telecommunications, and surveillance systems make extensive use of databases. However, in recent years,\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65975,"url":"http:\/\/bangla.sitestree.com\/?p=65975","url_meta":{"origin":69123,"position":3},"title":"Introduction to Spring #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 18, 2021","format":false,"excerpt":"Open-sourced on February, 2003 Layered J2EE application framework Inversion of Control (IoC): A Data Access Object (DAO) depends on a DataSource. Allows: code to interfaces Spring has classes to support Hibernate, Struts, and other frameworks According to many Java developers [ref:internet], J2EE patterns are sometimes cumbersome. Spring uses patterns but\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70061,"url":"http:\/\/bangla.sitestree.com\/?p=70061","url_meta":{"origin":69123,"position":4},"title":"Database Operation Handling in PHP #16","author":"Author-Check- Article-or-Video","date":"August 24, 2021","format":false,"excerpt":"Not the best approach. Just one approach. At least to help with thinking. to start with. < ?php \/\/you can keep database parameters in a file [text file or xml file]. \/* Create two users one with only read permission, another with read-write permission. Use read user related connection in\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65654,"url":"http:\/\/bangla.sitestree.com\/?p=65654","url_meta":{"origin":69123,"position":5},"title":"XML Related Classes in .Net #Misc .Net","author":"Author-Check- Article-or-Video","date":"July 10, 2021","format":false,"excerpt":"Brought from our old site (yes, very old short-note): http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=633&title=XML%20Related%20Clasees%20in%20.Net XML in ADO.net VB.NET C#.NET XML is the foundation of .NET. .NET internally represents data as XML and hence can provide inter-operability and interaction among applications written in different platforms and languages [.Net compatible]. XmlReader In .Net you can use\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/69123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=69123"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/69123\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=69123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=69123"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=69123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}