In Hibernate frist define ObjectRelationalMapping usoing XML document .hbm.xml
<hibernate-mapping> is the root element in that.
then map the java class with database table for that the code is.
<class name="java clas name" table="dbtablename">
primary key in <id> tag.
Automatical Generator value <generator class=" "/> native,identity,sequence.
Link the java class property to Database columns using <property name="" type="" col="" not-null="true/flase"> tag.
On Start up hibernate looks for a file called hibernate.cfg.xml in root of class path.
in this file wrote the information about dialet,driverclass,connectionurl,username,pwd.
If we set show_sql to true then it will display all executed sql queries on console.
add .hbm.xml file to the configuration.
<hibernate-configuration> is root element. then <session-factory>
<mapping resource=".hbm file>
Hibernateutil helps in creating SessionFactory from Hibernate Configuration File.
The dir structure will be like this...
HIbernateExample
src
com.**.**
.java file
.hbm.xml
com.**.util
hibernateutil.java
hibernate.cfg.xml
jre library
reference library
<hibernate-mapping> is the root element in that.
then map the java class with database table for that the code is.
<class name="java clas name" table="dbtablename">
primary key in <id> tag.
Automatical Generator value <generator class=" "/> native,identity,sequence.
Link the java class property to Database columns using <property name="" type="" col="" not-null="true/flase"> tag.
On Start up hibernate looks for a file called hibernate.cfg.xml in root of class path.
in this file wrote the information about dialet,driverclass,connectionurl,username,pwd.
If we set show_sql to true then it will display all executed sql queries on console.
add .hbm.xml file to the configuration.
<hibernate-configuration> is root element. then <session-factory>
<mapping resource=".hbm file>
Hibernateutil helps in creating SessionFactory from Hibernate Configuration File.
The dir structure will be like this...
HIbernateExample
src
com.**.**
.java file
.hbm.xml
com.**.util
hibernateutil.java
hibernate.cfg.xml
jre library
reference library