Hibernate

It is a popular open source object relational mapping tool for java platform.It provides powerful,ultra-high performance object/relational persistence and query service for java.

Object relational mapping(O/R mapping )

we mean the one-one mapping of class attributes with the columns of a database entity. Hibernate Hibernate maps java classes to the database tables.It also provides the data query and retrieval facilities that significantly reduce the development time. Hibernate allows transparent persistence that enables the applications to switch any database.Hibernate can be used in java swing apllications,java servlet based applications or j2ee apllications using EJB session beans.
Updated Solution to Hibernate errors

Sample Hibernate code using Mysql database This is the code for the java pojo classes ie getter and setter methods for the fields
What is Session Factory see with an example.

/*
Directory structure
Firsthibernate
->
s2s
->gateway
->example
->simpleobj.hbm.xml
->simpleobj.class (pojo class)

->hibernate
->HibernateSessionFactory
->Sessionfactory util
WEB_INF
->lib
hibernate.cfg.xml

In lib folder
put all libraries files as mentioned below if your lib jars of hibernate located in root folder ./WEB-INF/lib
or
give appropriate path.

Example path:
E:/firsthibernate>h.bat

E:/firsthibernate>set classpath=./WEB-INF\lib\mysql-connector-java-3.
0.16-ga-bin.jar;./WEB-INF\lib\antlr-2.7.6.jar;./WEB-INF\lib\hibernate-search.jar
;./WEB-INF\lib\hibernate-commons-annotations.jar;./WEB-INF\lib\hibernate-annotat
ions.jar;./WEB-INF\lib\log4j.jar;./WEB-INF\lib\ejb3-persistence.jar;./WEB-INF\li
b\slf4j-log4j12.jar;./WEB-INF\lib\slf4j-api.jar;./WEB-INF\lib\commons-collection
s.jar;./WEB-INF\lib\dom4j.jar;./WEB-INF\lib\lucene-core.jar;./WEB-INF\lib\common
s-logging-1.0.4.jar;./WEB-INF\lib\hibernate-core.jar;./WEB-INF\lib\ehcache-1.1.j
ar;./WEB-INF\lib\xml-apis.jar;./WEB-INF\lib\javassist-3.4.GA.jar;./WEB-INF\lib\e
hcache-1.2.3.jar;./WEB-INF\lib\junit.jar;./WEB-INF\lib\hsqldb.jar;./WEB-INF\lib\
thirdparty-all.jar;./WEB-INF\lib\hibernate-testing.jar;./WEB-INF\lib\hibernate-e
ntitymanager.jar;./WEB-INF\lib\jdbc2_0-stdext.jar;./WEB-INF\lib\cleanimports.jar
;./WEB-INF\lib\connector.jar;./WEB-INF\lib\concurrent-1.3.2.jar;./WEB-INF\lib\ja
as.jar;./WEB-INF\lib\jta.jar;

E:/firsthibernate>javac *.java

E:/firsthibernate>java TestClient
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment
).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select max(id) from simpleobj
Hibernate: insert into simpleobj (name, taste, id) values (?, ?, ?)
Hibernate: select simpleobj0_.id as id0_, simpleobj0_.name as name0_, simpleobj0_.taste as t
aste0_ from simpleobj simpleobj0_
Names of users:Andrew
Names of users:safiq
Names of users:north
Names of users:simpleforest
Names of users:north
Names of users:north
Names of users:north
Names of users:simpleforest
Names of users:simpleforest
Names of users:north
Names of users:north
Names of users:north
Names of users:north
Names of users:north
Names of users:north
Names of users:north
Names of users:north
Names of users:simpleforest
Hibernate: update simpleobj set name=?, taste=? where id=?

Create Database named car in mysql
create table simpleobj with id,name,taste
To know about mysql click the mysql tab above.

compile all
Javac *.java in all folders

finally run java TestClient

output
---------

mysql> use car;
Database changed
mysql> select * from simpleobj;
+----+----------------------+------------+
| id | name | taste |
+----+----------------------+------------+
| 1 | Andrew | roaming |
| 2 | safiq | web |
| 3 | north | very sweet |
| 4 | simpleforest | very sweet |
| 5 | north | very sweet |
+----+----------------------+------------+
5 rows in set (0.02 sec)

mysql> select * from simpleobj;
+----+----------------------+------------+
| id | name | taste |
+----+----------------------+------------+
| 1 | Andrew | roaming |
| 2 | safiq | web |
| 3 | north | region |
| 4 | simpleforest | very sweet |
| 5 | north | region|
| 6 | north | original |
+----+----------------------+------------+
6 rows in set (0.02 sec)