views:

25

answers:

2

Hi,

What the exact purpose of ' native ' in hibernate mapping file of the generator tag ( I know by using genarator tag, it will genaerate the primarykey values ...)

....... ..........

+1  A: 

It uses the generation strategy that is best suited for the database. From the hibernate docs:

native - selects identity, sequence or hilo depending upon the capabilities of the underlying database.

The reason this is necessary is that there is no identity type that is common to all databases. In the case where the database doesn't even support an int/long identity type, hi/lo generation strategy is necessary, which is a hibernate-generated id.

If you know the specific database you are working with, then you can name a specific identifier generation scheme to use. But for cross-db development, using native means the application has more chance of being portable across different dbs.

mdma
ok. thanks for replying.I understood thatidentity related to type.what about the hilo generation strategy????
CHANTI
@CHANTI - please see the link I gave to the documentation. It describes the hilo strategy in more detail than is possible here.
mdma
A: 

native means that the database's means are used to generate the primary key values. E.G. a Sequence in Oracle 10g and AUTO_INCREMENT for mysql.

Hope that helped..

smeg4brains
ok.I understood that,native represents the respective databases...
CHANTI

related questions