Yes you must have an id to uniquely identify the object to one and exactly one record/row/tuple in the database.
I usually choose auto for the generation type to allow Hibernate to just use the underlying databases generation type, this leaves you code generic enough for switching out databases.
Originally posted by Nakata kokuyo: Mark, i assume auto generate means by increment ?
No, actually in the mapping file it is called "native" in JPA it is called Auto. "increment" works with MySql, but not Oracle which would need "sequence", but if I had "native" then it covers both MySql and Oracle because the dialect will tell which one the vendor natively uses.
Mark
Nakata kokuyo
Ranch Hand
Joined: Apr 13, 2005
Posts: 437
posted
0
Cool Mark, thanks for the guidance
subject: is it a must to have id for each mapping file ?