| Generator |
Description |
| increment |
It generates identifiers of type long, short or int that
are unique only when no other process is inserting data into the same
table. It should not the used in the clustered environment. |
| identity |
It supports identity columns in DB2, MySQL, MS SQL Server,
Sybase and HypersonicSQL. The returned identifier is of type long, short
or int. |
| sequence |
The sequence generator 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 |
| hilo |
The hilo generator uses a hi/lo algorithm to efficiently
generate identifiers of type long, short or int, given a table and
column (by default hibernate_unique_key and next_hi respectively) as a
source of hi values. The hi/lo algorithm generates identifiers that are
unique only for a particular database. Do not use this generator with
connections enlisted with JTA or with a user-supplied connection. |
| seqhilo |
The seqhilo generator uses a hi/lo algorithm to
efficiently generate identifiers of type long, short or int, given a
named database sequence. |
| uuid |
The uuid generator uses a 128-bit UUID algorithm to
generate identifiers of type string, unique within a network (the IP
address is used). The UUID is encoded as a string of hexadecimal digits
of length 32. |
| guid |
It uses a database-generated GUID string on MS SQL Server
and MySQL. |
| native |
It picks identity, sequence or hilo depending upon the
capabilities of the underlying database. |
| assigned |
lets the application to assign an identifier to the object
before save() is called. This is the default strategy if no
<generator> element is specified. |
| select |
retrieves a primary key assigned by a database trigger by
selecting the row by some unique key and retrieving the primary key
value. |
| foreign |
uses the identifier of another associated object. Usually
used in conjunction with a <one-to-one> primary key association. |
Current Comments
25 comments so far (post your own) View All Comments Latest 10 Comments:iam doing a project matrmonial iwant to develop REGISTRATION FORM.PLS HELP ME
Posted by chalamreddy on Monday, 07.28.08 @ 18:44pm | #69565
Hi,
I have an entity object which have an id with sequence generator. in some case i want to override this generator if the id is being passed by entity object. Is it possible to achieve this by <generator class="sequence"> itself?
Please help me on this
Posted by Jeya Uma on Tuesday, 06.10.08 @ 18:50pm | #62897
hi
Posted by Raveendra on Monday, 05.19.08 @ 16:50pm | #60451
hello everybody ...
For the single primary key.not at all a problem. we can work it out. But what to do with composit primary key.i.e. in a table primary key is made up of combination of more than one field.
regards
uday bhat
Posted by uday bhat on Tuesday, 05.6.08 @ 12:01pm | #58608
When i tried with the example given, only tables are created. But data is not inserted ...
I tried like this..
create a transaction object(tx) with the session i.e session.beginTransaction(). and then tx.commit() to commit the transaction. Then my data is updated and inserted in the table.
I think by default autocommit may be false.
Enjoy..
Mythili
Posted by Mythili on Wednesday, 04.30.08 @ 15:36pm | #58212
Hi, I'm trying to generate an id in hibernate in a specific format i.e. i want it to appear 0001,0002, etc ...
Here is the code I use in my request.hbm.xml file
<id name="requestId" column="REQUEST_ID">
<generator class="increment"/>
</id>
but this generates the ids 1,2,etc...
Any idea's?
Posted by Amanda Sweeney on Thursday, 03.6.08 @ 15:39pm | #51693
Hi,
I writtenexaple in that in i mentioned generator class="sequence" but its giving fallowing exaception can any help me to solve that problem.
error like this:
org.hibernate.HibernateException: identifier of an instance of com.Honey altered from 2 to 2
if i use class="genarator" its working fine.
Posted by Ravi Kumar on Monday, 02.4.08 @ 22:26pm | #47214
Hi RoseIndiaTeam,
who is the subject matter expert in maintaining this site for java in RoseIndia? really i want to talk to them once .......
very nice site for Java Developers.
the structure, point wise explianation is really heart touching
keep on updating the site ............
stephen
09818827207
Posted by T.Stephen on Wednesday, 01.30.08 @ 19:17pm | #46617
I am new to Hibernate. I have tried with given example source . All the mapped tables are being created but data is not been inserted in table. Even there is no exception. Can you please guide me what could be possible reason for this??
Posted by Shikhar on Tuesday, 01.29.08 @ 17:25pm | #46497
Hi,
Im new to Hibernate as well as MyEclipse5.1.
When Im reverse engineering the required table in the opened Database connection Im able to create the Dao file xml file and everything but when Im using the HQL editor to access the table it is sayin that the table is not mapped from the table.
can u plz help me out with this
Uma
Posted by uma on Saturday, 12.29.07 @ 17:02pm | #44135