• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CMP 2.0 - how to autogenerate a PKey?

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all-
I'm writing Entity beans using CMP 2.0 in WSAD 5.1.1 and DB2 v 8.1.
The PK is a sequence.
My problem: how to create an entity bean and let the container/db generate the PK. SQL will auto-generate just fine (if the PK is not specified) but not CMP it appears. I've seen solutions where the key is calculated prior to the create (suign SQL) but I would like a more elegant solution.
thanks
Max
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi max ,

The Primary Key its YOUR WORK ! , the EJB CONTAINER does not generate the primary key for you because its don't know what's about your bean / your code, once that's no way to say to EJB Container that a field is auto generate primary key ...


hope this help ...

Regards,

Paulo Nunes
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply-
I've since learned that WAS does NOT support this feature (although other containers do, a real oversight IMHO)...
anyway, there are multiple strategies for doing it yourself�
We settled for generating a String GUID and not using an autogenned ID�
if anyone is interested, a good link is:
http://www-106.ibm.com/developerworks/java/library/j-ejbdesign.html?dwzone=java
 
reply
    Bookmark Topic Watch Topic
  • New Topic