This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Regarding PK" Watch "Regarding PK" New topic
Author

Regarding PK

georgejk
Greenhorn

Joined: Jul 29, 2002
Posts: 24
Hi
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.
Thanks
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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.
Thanks!
Simon
Bartender (moderator) of "J2EE and EJB" forum
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Hi George,
There are several "patterns" available for handling automatically generated, surrogate, primary keys. Here is an article that discusses the issue:
http://www.flashline.com/content/mclaughlin/bm050701.jsp?sid=1011641712765-216531326-51

And the book "EJB Design Patterns" by Floyd Marinescu also discusses this issue. You can download a PDF version of that book from here:
http://www2.theserverside.com/books/EJBDesignPatterns/index.jsp

Good Luck,
Avi.
 
Don't get me started about those stupid light bulbs.
 
subject: Regarding PK
 
Similar Threads
Question about composite primary key in JPA.
Please help me on using EJB-QL with JBoss 4.0
set accessor method for PK
Primary Key auto generation
Oracle help urgent