Exampleto insert the record in the database. --------------- Student class(java class) Student mapping document(xml) Hibernate configuration document(xml)Hibernate client Student-table Write one persistence class with the name student.java which contains private field and public fieldset/get methods Create the table called studenttable in database. Writeonemappingdocument withthename!student.hbm.xml" Whichcontainsmappingbetweenpersistence class fields and database table columns. Write one hibernate configuration document which contains the information about #our database li$edriver class%&'( username( password etc.!hibernate.cfg.xml." %ser mapping)client program which uses the hibernate *+, to do the persistence operationli$e insert delete( update etc. -pen the eclipse and create the java project. *dd the hibernate capabilit# for the java project as follows &ight clic$ on project clic$ on .#/clipseadd Hibernate capabilities Clic$ on next buttonclic$ on next button. %nchec$ed the 0st chec$box for specifies the database connection details. Clic$ on next button unchec$ the chec$box for the create Session1actor# class then finish(clic$)2ow #ou can see the following director# structure in eclipse// application0 name of the project Student.java Hclient.java Student.hbm.xml SidSname/mail+hone1ee ,ntCharChar'ong3ouble*pplication0hibernate.cfg.xml (b# default )45&/ 0.6 'ibraries Hibernate 7.0 core 'ibraries &eference libraries .#s8l.jar SrcHibernate code to insert therecord in databaseHIBERNATESteps to develop 1st hibernate exampleevelopin! hibernate application in Eclipsecom.jlc.hibernate1"#$%#&$$% Create the pac$age called com.jlc.hibernate in src folder.1iles re8uired) Student.java Student.table Student.hbm.xml Hibernate.cfg.xml HClient.java Hibernate is an open source framewor$ from redhat division. Some other product from the redhat is 'inux( 4boss application server( 4boss S/*.. *rchitecture of hibernate is 9avin :ing. Hibernate is persistence framewor$ which allows #ou to do the persistence operation (database operations) in the easiest wa#.'ollo(in! are the various persistence )rame(or*s or technolo!+ is available in mar*et, ----I. I#- Stream, ---------Seriali.e II. /B0 III. 123 4-2 A5I6 -2 ------------- document ob7ect model I8. Hibernate Hibernate A5I 8. E/B &.18I. E/B ".$ 4/5A) // java persistence *+, 8II. IBatis8III. /-//java database object Hibernate is the best persistence framewor$ among all the others persistence framewor$.Hibernate0st example1st Hibernate pro!ramHIBERNATE4ava object 'lat )ileB2SRB2S /ava class 4ava object 1ml 4ava object RB2S -&.(object relational mapping ) concept )it is completel# implemented in hibernate . So #ou can sa# hibernate is the best -&. tool among other -&. tools li$e /4; 5.x ( /4; 7.ou can also use some third part# connection management in #our hibernate application and #ou can also use #our own connection management. third part# connection management and #our customer management can be integrated hibernate ver# easil# Hibernate provides powerful object oriented 8uer# language(--?') 0st --?' is introduced b# S%2 in /4; as !/4;?'".Hibernate provides the )ollo(in! :uer+ lan!ua!es H?' Hibernate ?uer# 'anguage ?;C ?uer# ;# Criteria ?;/?uer# ;# /xample *s -&. tool hibernate also supports stored procedure invocation.
+ersistence manager ,n the above hibernate s#stem there are some high level components and some low level components.1ollowing are the high level components which will be used b# hibernate developer) Configuration Session1actor# Session @ransaction 1ollowing are the low level components which will be used b# hibernate s#stem internall#. Connection+rovider ConnectionHibernate Architecture4ava application which is using hibernate s.save(stu)A@ransient object Hibernate s+stem 3atabase server +ersistence object 3etached object Configuration Session1actor#Session @ransaction C-22/C@,-2+&-B,3/&@&*2S*C@,-21*C@-&>43;C*+,423, *+,4@**+,C-22/C@,-2 @ransaction1actor# 43;C *+, 423, *+, 4@* *+, Configuration is a class which is available in !org.hibernate.cfg !pac$age . Hibernate runtime s#stem will be stored b# installing configuration class 0st .Configuration class has two implement methods as follows) Configuration configure()Configuration configure(string) Configure () method is responsible to read all the propert# defined in hibernate configuration documents and all hibernate mapping documents. *fter reading all the properties from hibernate configuration and mapping documents configuration object is responsible to create the Session1actor# object. -nce the session factor# is created there is no use with configuration object. Session is an interface( which is available in !org.hibernate" pac$age. Session factor# is long live multithreaded object. %suall# one session factor# should be created for one database. When#ouhavemultipledatabasesin#ourapplication#oushouldcreatemultipleSession1actor#object. *ssume the scenario that #ou are using one database called m#s8l in #our application then following isthe wa# to create the Session1actor# object.0on)i!uration c)!;ne( 0on)i!uration46