Hi,
along with "assigned" and "native" there are many other generator types, see
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.htmlchapter 5.1.4.1. Generator
Quote:
My code works best when I use the 'native' generator however to match the fact that MySQL auto generates a new id when a new row is inserted.
Yes, 'native' generator is very comfortable for this purpose.
Anyway this approach has some serious disadvantages:
1. Performance:
With 'native' generator the row is inserted immediately when persisting a new object.
With the other approaches the inserts are deferred to the flush/commit action and can benefit from the batching feature.
2. Traceability: when enabling sql-logging with 'native' generator you cannot see with which ID the new persisted object was inserted into database.