File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Regarding PK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Regarding PK" Watch "Regarding PK" New topic

Regarding PK


Joined: Jul 29, 2002
Posts: 24
Just look into the scenario in which i have set the primary key field as auto generated. In that case my CMP representing to that table is giving me error when i try to call the create method.
The create method is called by passing the other fields in that table. So in my point of view it should insert to that table with the values supplied. Because one trigger is created to generate the PK as automatic.
The error was primarykey field not initialized.
If anyone can suggest me an idea that would be fine.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
Hi there...
Thanks for joining us here at the ranch, but could you just take a quick look at the naming policy and edit your profile accordingly.
Bartender (moderator) of "J2EE and EJB" forum
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi George,
There are several "patterns" available for handling automatically generated, surrogate, primary keys. Here is an article that discusses the issue:

And the book "EJB Design Patterns" by Floyd Marinescu also discusses this issue. You can download a PDF version of that book from here:

Good Luck,
I agree. Here's the link:
subject: Regarding PK
It's not a secret anymore!