Loading
Generate IDs in Hibernate

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  How many ways you could generate IDs in Hibernate ?


Ans)

There are so many ways of generating Ids in Hibernate , but the following are
mostly used

increment

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.

identity

Supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL.
The returned identifier is of type long, short or int.

sequence

Uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase.
The returned identifier is of type long, short or int

<id name="id" type="long" column="cat_id">
        <generator class="org.hibernate.id.TableHiLoGenerator">
                <param name="table">uid_table</param>
                <param name="column">next_hi_value_column</param>
        </generator>
</id>


<id name="id" type="long" column="person_id">
<generator class="sequence">
 <param name="sequence">person_id_sequence</param>
</generator>
 </id>



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Generate IDs in Hibernate


Generate IDs in Hibernate

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free