Database generated primary keys and Entity EJB's (CMP)
1 posts in topic
Flat View  Flat View

Posted By:   Nic_Bennett
Posted On:   Tuesday, November 20, 2001 08:27 AM

How can I let the database generate the primary key of a row when inserting into a table using a CMP entity EJB. Also how can I find out what key was generated after the row has been inserted. I am using WebSphere/VisualAge for Java and IBM access beans.

Re: Database generated primary keys and Entity EJB's (CMP)

Posted By:   AlessandroA_Garbagnati  
Posted On:   Thursday, November 22, 2001 01:24 AM


My personal opinion: since I like to have portable solution, I don't normally like to use the autoincrement fields or sequences that are handled by the database, because when it happens to switch from one db to another these features can be handled in a different way or, even. they aren't present at all.

There are many interesting patterns you can use for solving this problem, and I've used a couple of them. You can find interesting solutions here:

There is also this other interesting solution: GUIDs without Singletons and Databases.
About | Sitemap | Contact