• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to create a Entity Bean with no primary key?

 
senthilkumar ap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all..,
Is it possible to create a Entity Bean with no primary key?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. But then, if you are using a relational database why would you?
 
senthilkumar ap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is like that .. i need to have some snapshot tables for their original table.. here my snapshot table should contain columns same as original table and one additional column for time.. whenever there is update in original table then those old values has to be inserted into snapshot tables.. so there is no possibilities to have unique field.. then how can we do this?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any reason why you don't define your history table with a surrogate key?
 
senthilkumar ap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your suggestion .., finally im planning to move with surrogate key., and i have another issue., the datas will be retrieved from snapshot table based on time, what can i do if time contains duplicate values..?






Thanks for your time
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing. Is this an issue?

Timestamps may not be unique. If you need them to be (though I'm not sure why if you have a surrogate key) you should add a unique index to that column. If you are using a time stamp as your versioning column you might consider using an integer instead.
 
senthilkumar ap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im novice.., could you elaborate little bit more what should i do?
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic