aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes primary key generation in CMP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "primary key generation in CMP " Watch "primary key generation in CMP " New topic
Author

primary key generation in CMP

Andron Dre
Greenhorn

Joined: Nov 16, 2001
Posts: 12
We are using db2 sequence for primary key generation. Session bean gets next sequence number and put it into create method of entity bean.
I wonder if it make sense to put this call inside create method and remove pk from parameters list. Please keep in mind that it’s CMP.
thx in advance
amit indian
Greenhorn

Joined: Nov 04, 2001
Posts: 22
of course this would be the right approach ,
what is the use of passing one more parameter from bean to bo man ?
and so what if it is cmp , u dont pass the primary key but pass all other things , and then take the key from ur id generator and use it there only.
we do the same in our case
so enjoy


SCJP-2 <br />Senior Software Programmer.
Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 211
Andron : Would you tell me how to get the next sequence number you described in your message?


Thanks
Benson
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The minimum requirement for the ejbCreate() method is to make the PK and assign it to the primary key field. You will, however, return null from this method in order to be compliant with the EJB spec.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
WARNING! This will NOT work in all CMP implementations! For instance, WebSphere does not support this. Currently there are vendor-specific support for this in some servers, but not in all. This is outside the 2.0 CMP spec, and is not guaranteed to be portable!

Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: primary key generation in CMP