Identity columns and sequences in Hibernate

By: Dorris Emailed: 1607 times Printed: 2076 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

C:\Users\User\amaya\2\New.html

For databases that support identity columns (DB2, MySQL, Sybase, MS SQL), you can use identity key generation. For databases that support sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you can use sequence style key generation. Both of these strategies require two SQL queries to insert a new object. For example:

<id name="id" type="long" column="person_id">

<generator class="sequence">

<param name="sequence">person_id_sequence</param>

</generator>

</id>

<id name="id" type="long" column="person_id" unsaved-value="0">

<generator class="identity"/>

</id>

For cross-platform development, the native strategy will, depending on the capabilities of the underlying database, choose from the identity, sequence and hilo strategies.


Hibernate Home | All Hibernate Tutorials | Latest Hibernate Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(1)


1. View Comment

This was the first clear and straight-forward example I have seen, thank you

View Tutorial          By: Steve at 2013-01-02 22:58:32

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Dorris
sum of all digits in a given number using Shell Script
sh -x and sh -v in Linux
case..esac..in Linux Shell Script
while loop in Linux Shell Script
Nested for loop in Linux Shell Script
for loop in Linux Shell Script
Multilevel if-then-else in Linux Shell Script
Nested if-else-fi in Linux Shell Script
if...else...fi in Linux Shell Script
test command or [ expr ] in Linux Shell Script
if condition in Linux Shell Script
Download Linux. Which linux and where?
Formula in Hibernate
Primary keys assigned by triggers in Hibernate
Assigned identifiers in Hibernate

More Tutorials in Hibernate
Fetching strategies in Hibernate
equals() and hashCode() in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
EntityNameResolvers in Hibernate
Hi/lo algorithm in Hibernate
Identity columns and sequences in Hibernate
Assigned identifiers in Hibernate
Primary keys assigned by triggers in Hibernate
Formula in Hibernate
Step by Step Hibernate - Your First Hibernate Application
A sample Hibernate Web Application using Servlets
Some Basic APIs in Hibernate
Contextual sessions in Hibernate
Programmatic configuration in Hibernate
SessionFactory in Hibernate

More Latest News
Most Viewed Articles (in Hibernate )
Creating Connection Pool for JDBC Connections in Hibernate
Hibernate Vs. JDBC ( A comparison)
Step by Step Hibernate - Your First Hibernate Application
Hibernate Configuration Properties
Download Hibernate latest version
A sample Hibernate Web Application using Servlets
Hibernate Transaction Properties
Fetching strategies in Hibernate
equals() and hashCode() in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
EntityNameResolvers in Hibernate
Identity columns and sequences in Hibernate
Formula in Hibernate
Types of inheritence models in Hibernate
What is component mapping in hibernate?
Most Emailed Articles (in Hibernate)
Hibernate Vs. JDBC ( A comparison)
Hibernate Transaction Properties
Tutorial Using the Java Persistence API (JPA) in Hibernate
A sample Hibernate Web Application using Servlets
Programmatic configuration in Hibernate
Tuplizers (org.hibernate.tuple.Tuplizer) in Hibernate
EntityNameResolvers in Hibernate
Delta Electronics Chairman Bruce Cheng Endows NCKU Build Y.S. Sun Green Building Research Center
What is component mapping in hibernate?
Download Hibernate latest version
Creating Connection Pool for JDBC Connections in Hibernate
Paging Through the Result Set in Hibernate
Hibernate Configuration Properties
equals() and hashCode() in Hibernate
Hi/lo algorithm in Hibernate