Hibernate generator Element

In this tutorial you will learn about the hibernate's element.


 

Ads

Tutorials   
How to write hello world example program in Hibernate? How to create one to one relationship in Hibernate 4 with Annotation? How to calculate minimum in Hibernate using the min() Function Hibernate 4.3.4 Released: Hibernate 4.3.4.Final Maven dependency Hibernate 4.3 Hello World: Example How to create SessionFactory in Hibernate 4.3.1? Hibernate 4 Hello World: Example of Hello World program Hibernate 4 create Session Factory: Example of creating Session Factory in Hibernate 4 Hibernate 4.3 and JPA 2.1 Example What is Hibernate in Java? Hibernate Overview and Architecture What is JPA 2.1? Hibernate 4.3.0.Final Maven dependency Hibernate 4.3 ORM Features Hibernate 4.3 Tutorial Hibernate Criteria average example Hibernate Criteria load all objects from table Hibernate Criteria Hibernate beginner tutorial Hibernate Session.delete() Example Hibernate save or update method example Hibernate Load Example Hibernate save Example - Rose India Hibernate 4 tutorials Hibernate Example Step by Step in Eclipse Hibernate Configuration files Setup Hibernate Environment Hibernate Architecture Hibernate Overview Hibernate 4.2 Tutorial Hibernate 4 Annotations Tutorial Hibernate 4 AnnotationSessionFactoryBean hibernate versions hibernate jndi hibernate tomcat hibernate metamodel generator hibernate entity Seam Hibernate C3P0 Hibernate hibernate shard hibernate means temporal hibernate jsf hibernate spring j2ee hibernate spring hibernate encrypted password alias_to_entity_map hibernate temporal jsf spring hibernate hibernate by example hibernate repository hibernate sample code
Ads

Hibernate <generator> Element

In this tutorial you will learn about the hibernate's <generator> element.

<generator> is an optional child element of the element <id>. In <generator> a class name is to be assigned using which unique identifier is generated for the new record at the time of new record is saved. For example :

<class name="roseindia.Employee" table="employee">
<id name="empId" type="long" column="Id" >
<generator class="assigned"/>
</id>

A simple interface org.hibernate.id.IdentifierGenerator is implemented by all generators. Hibernate provides a various built-in implementations some of them built-in generators are as follows :

shortcut name for the built-in generators Description
increment For the type long, short or int identifiers are generated these
identifiers will not be remain unique if any other process inserts
data into the same table. It should not used in the
clustered environment.
identity In DB2, MySQL, MS SQL Server, Sybase and
HypersonicSQL an identity column is supported. The returned
type of an identifier may be long, short or int.
sequence In DB2, MySQL, MS SQL Server, Sybase and
HypersonicSQL an identity column is supported. The returned
type of an identifier may be long, short or int.
assigned This generator lets to assign an identifier to the object by
application before calling the save(). A default strategy if
generator element is not specified.
select This generator retrieves a primary key and primary key value
by selecting the row by some unique key that are
assigned by a database trigger
foreign This generator uses the identifier of another associated object.
Commonly used in conjunction with a primary key association.
sequence-identity Only supported by Oracle 10g drivers. It is a specialized
sequence generation strategy. For the actual value generation
it uses a database sequence.

Advertisements

Ads
Share on Google+Share on Google+

Hibernate generator Element

Posted on: February 17, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Hibernate Element  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads