Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

primary key generation in CMP

 
Andron Dre
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Benson Fung
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andron : Would you tell me how to get the next sequence number you described in your message?


Thanks
Benson
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic