Hibernate: Using ‘native’ identifier generation

The nice folks at Apress sent me a couple books (Enterprise Java Development on a Budget: Leveraging Java Open Source Technologies, Pro Jakarta Struts and Beginning J2EE 1.4: From Novice to Professional) to review. Last night I was glancing through the object relational mapping chapter of the Enterprise Java Development on a Budget book and read about mapping identity columns using Hibernate. The sites I work on are mostly SQL Server and MySQL, so I’ve been using the ‘identity’ generator, which “… supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL.” (in contrast to the sequence generator which uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase) The book mentioned that the ‘native’ generator “… intelligently chooses the appropriate strategy” from among the identity, sequence or hilo generators. Hibernate never ceases to amaze.

2 thoughts on “Hibernate: Using ‘native’ identifier generation”

  1. Thats true….
    I am facing a major problem when migrating from oracle to db2.
    This native generator works fine with oracle and uses given sequence to generate id, but it doesnt work with db2…strange !!!

  2. I can’t get native to work with mysql. As long as I have auto_increment on, everything is fine, but since I wan’t my code to be portable i turn it off and then it breaks because it fails to generate a new unique number. bugger…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>