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).
There's a good desc in ejb patterns at theserverside.com
Joined: Jul 28, 2002
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?