putting the @ejb.pk-field entry back on the getId() method generates a correct getPrimaryKey()
Harkness, David wrote:
bob combs wrote:
org.jboss.deployment.DeploymentException: Field id in prim-key-class
must be the same type
Ah yes, note to self: reply *after* coffee. By using a custom PK class, you still need to map the individual fields (one in your case) using the types in the PK class. So you need
public abstract String getId(); public abstract void getId(String id);
in the bean. Since you have a single-column PK, do not mark the accessors with @ejb.pk-field. Instead, use the class-level tag @ejb.primkey-field (note that you have pk-field at the class level, which is incorrect).
Now, you'd like to be able to access the actual PK of the bean from the VO. Is that correct? You can certainly access the String id field in the VO, but you'd like the UUID form. [Note that if you want a getUUID() method in the bean, you could cast the result of bean.getEntityContext().getPrimaryKey().]
One thing before I forget. In your ejbCreate, I believe you shouldn't call setId(uuid) but instead return the created UUID and let the CMP layer map it to the individual fields (again just one). I'm letting WebLogic generate PKs using Oracle sequences, so this is yet another area I haven't tried myself.
Looking in the generated VO code for my beans, there *is* a getPrimaryKey() method returning Integer (the PK field's type). Is it not generated as a UUID for you already?
To summarize,
- Map "id" field as a String in the bean, not as UUID.
/** * Returns the id * @return the id * * -- DEPRECATED @ejb.persistent-field * @ejb.persistence * column-name="ID" * sql-type="CHAR(32)" * -- UNNECESSARY (though I see my beans have this too) @ejb.pk-field * * @ejb.interface-method */ public abstract String getId(); public abstract void getId(String id);
- Remove @ejb.pk-field tag from "id" field accessors. Reason: Use class-level tag for single-column PKs.
- Change class-level tag from @ejb.pk-field to @ejb.primkey-field.
- Optionally add getUUID() method to bean that casts the result of context.getPrimaryKey(). It will *not* be a persistent field but rather a business method; just expose it on the interface if you'd like.
Once that's complete, generate the VO and look at the definition of getPrimaryKey(). Does it have the correct type (UUID) already? If so, can you live with that name instead of getUUID()? If not, you'll need to put it into the custom merge point or modify the template itself.
David Harkness Sr. Software Engineer Sony Pictures Digital Networks (310) 482-4756
------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From_______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user