Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do DB-Auto-Generated Primary Key in EJB 2.0?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I make my bean a CMP bean, but have the ID field auto-generated by a database? Also, I have two other questions: 1. Why isn't this in the EJB 2.0 spec? 2. Other than using an auto-generated field, what would be another good way to do a primary key? Or a better way? Obviously, the people who did the spec must think they're not a good idea, because they didn't make it part of the spec (db-generated AND non-db-generated, ALL auto-generation of primary key is not included).
 
Sam Wang
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a good desc in ejb patterns at
theserverside.com
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, their suggestion for a database-generated ID is for BMP beans only. I need something for my CMP bean. And their other solutions are not very good performance-wise, and not quite as safe and garaunteed to be unique. Using another bean to generate the ID's? That more DB calls! Ugh.
Why is this NOT a part of the EJB spec? What did they expect us to do for primary keys? Am I missing something? What else would people do? What's wrong with auto-generated IDs?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic