identity « Key « JPA Q&A





1. JPA with byte primary key and GenerationType.IDENTITY    forum.hibernate.org

Hello, I am currently using hibernate 3.6.0.Final as JPA implementation. I have an entity where I would like to use a primary key with "java.lang.Byte" as datatype. Code: @Entity public class EntityByte implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) ...

2. Surrogate keys and business identity    forum.hibernate.org

I agree with the direction of Hibernate and the manuals that stress the use of surrogate keys for tables. This simplifies RI and makes more sense than relying on the "unchangeable" business attributes. I am looking for ideas on how others handle the requirements for uniqueness of business attributes. Example: A course at a college has a number that is unique ...

3. Audit Log does not work with identity key generation    forum.hibernate.org

I have implemented an audit log using Interceptor.onFlushDirty, using the increment key generation strategy. When I changed the key generation strategy from increment to identity column, onFlushDirty was not called any more and onSave had an id which was null. The only method which knows the correct id was postFlush(), but postFlush() is called more than once with the same object ...

4. Foreign key based upon identity in parent    forum.hibernate.org

I have a scenario where I have a parent and child relationship. The parent's primary key is an identity and there is a one to many relationship between the parent and the child. How do you tell Hibernate to propogate the generated identity in the parent to the foreign key field in the child? I currently have in the parent mapping ...

5. Identity error with foreign keys    forum.hibernate.org

I'm pretty new to Hibernate and am running into a simple problem: I have 2 tables user, userattributes. The userattributes table has a foreign key (userid) from the user table. the userid key is specified as a native generator and so is the userattributeid key. When I create an instance of the DAO and try to invoke the save method on ...