• 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

Unknown primary key class

 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Section 10.8.3 of the spec mentions about the Unknown Primary Key class. I am not able to understand this thoroughly. Specifically, the third paragraph:

When defining the primary key for the enterprise bean, the Deployer using the Container Provider�s tools will typically add additional container-managed fields to the concrete subclass of the entity bean
class (What does this mean??).
In this case, the Container must generate the primary key value when the entity bean instance is created (and before ejbPostCreate is invoked on the instance.) How does the container generate the primary key here??

 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, the "typically add CM fields to the concrete subclass of the entity bean". Note this is a "typically" used way, but not mandatory, it may work with fields already in your abstract bean class. This strategy is to extend the bean class to add one field (or more) that will hold the primary key value. Then, describe in deployment descpriptor a way to generate a value for this field. This mechanism usually uses container-specific tools/features (and some times also DB-specific features).

Have a look at this :


Here you have jboss specific unknown pk class elements added to DD, to describe the new field, and outside of the enterprise-beans block, another specific feature describing tke PK value generator.

This example shows how to declare a new field (here JBOSS will add a new field of java.lang.Integer type to the bean subclass) and how the container generates the key value (it calls the generator class defined at the end to get a value for the PK).

Note that a generator is not necessary. Here is an example of PK generation examples in Geronimo EJB container :



Here any of the generator may be selected to get a PK value each time container needs one.

JBOSS also can use several ways to generate a key. Look this adress to see how it can do: JBOSS key generators

Hope it clarifies the thing.
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it does clarify ...

This had been totally unexplored area for me ... anyway thanks for clarifying.
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic