Are You Recruiter/Hiring Manager

*Filter candidates using TestYourCandidate.com and save 80% time ( saving time for recruiters and interviewers)
*More than 50% candidates can be filtered on Candidate Screening online tests
*Inbuilt exams are available in library, created and tested by experts Try Today...

Hibernate Tutorial Step by Step -- Code Examples

Hibernate <generator> to generate id (primary key)

The optional <generator> child element names a Java class used to generate unique identifiers for instances of the persistent classincrement generates identifiers of type long, short or int that are unique only when no other process is inserting data into the same table. Do not use in a cluster.
Follow the setps :

Hibernate Session is the main runtime interface for Hibernate which is used for DataBase operataion. Session has the method like save () , update () , creteQuery() for Data Base operation. You can get session using SessionFactory.openSession() method. SessionFactory allows application to create the Hibernate Sesssion by reading the configuration from hibernate.cfg.xml file. Then the save () method on session object is used to save the contact information to the database.