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 ...)
....... ..........
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 ...)
....... ..........
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.
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..