Harkness, David wrote:
Gary Bennett penned

  
I've been trying to create an EJB with a composite key  using
xdocltet. 
Whenever I try to generate it XDoclet throws out the following. 'There
com.premita.dcp.ejb.Service_ElementBean bean has a compound key.
Please 
specify pk-field'
    

It seemed you were specifying pk-field for multiple fields along with
the PK class itself, so I don't see the issue. I did see a few things
that look a little suspect, though.

First, @ejb.persistent-field is deprecated and not needed -- perhaps
it's confusing XDoclet? Also, you specified several fields as having a
SQL type of "INT" and JDBC type as "VARCHAR", yet the Java type was
Integer.

Here's how I've defined the PK in all of my classes. Mind you, I'm not
using composite keys nor PK classes, but this should look the same since
I'm specifying (unnecessarily in my case) pk-field.

  /**
   * Returns the unique ID of this entity bean.
   *
   * @ejb.pk-field
   * @ejb.interface-method
   * @ejb.transaction type="Supports"
   * @ejb.persistence column-name="id"
   */
  public abstract Integer getId ( ) ;

Good luck!

  
I've tried making changes to match your suggestion but to no avail. Something strange is definitely going on as I've noticed that some of my primary keys are not being generated properly. Ie. Integer fields are being generated as Strings. If I do not use 'Composite' keys the generation works perfectly. In this case as the database is designed in house I can alter the design to avoid composite keys, although the DB designer is not very happy. It would be nice however if this problem could be resolved.

Has anyone managed to generate EJBs with composite keys?

Apologies the primary key string fault was entirely my own.

I do still have the composite key problem.

Reply via email to