Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persisting Entity with composite key is not working

Shaily Shah
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

Any help is greatly appreciated.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic