Persisting Entity with composite key is not working
posted 5 years ago
I am using Spring3 and hibernate3 and JPA annotations. I have an entity class which has composite key as a primary key. Two columns id and created_time defines primary key. Out of these two columns id is generated using a sequence and created_time is something which we set on entity object.
I have my entity class defined as below with a separate class for primary key.
My DAO has a call to save this entity:
The problem is when I am trying to save this entity using code above, the sequence number generated for the field "id" is totally incorrect. I don't understand why it is doing this. I am new to spring and hibernate. If any can tell me if I am doing something wrong. Let me know if any more information is required.