Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the best way to generate the primary key for entity bean

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
i am the beginner to entity bean,and usually use the toplink as the o-r mapping tool.it can generate the unique primary key automatically for me,i don't need to worry about it.
now i transfer to entity bean,i found that i must generate the pk in my code(if i use the integer id as primary key),then invoke the "create" method to insert a record to database,but how can i keep the id unique?
who can introduce me the best mechanism to generate pk for the entity bean?
thank you very much!
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at EJB design patterns, by floyd marinescu.
You can find a free PDF copy of the book at www.theserverside.com. It's got different patterns on how to generate keys.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic