> I've noticed that in my bean class if I specify a method like:
> 
> /**
>     * @ejb.interface-method
>     * @ejb.persistence
>     *
>     * @return String
>     */
>    public abstract String getState();
> 
> The resulting output in jbosscmp-jdbc.xml looks like:
> 
> <cmp-field>
>     <field-name>state</field-name>
> </cmp-field>
> 
> If the column name in the database is the same as the object's 
> field-name do I still need to specify the column-name attribute 
> underneath @ejb.persistence?  Or do I only need to specify the 
> column-name when it is not equivalent to the field-name?

You only need to specify column-name if the one JBoss uses does not match
existing db structure, or you don't like the name it uses (just the field
name).

> If I have the following method:
> 
> /**
>     * @ejb.interface-method
>     * @ejb.persistence
>     *     column-name="address_id"
>     * @ejb.pk-field
>     *
>     * @return Integer
>     */
>    public abstract Integer getAddressId();
> 
> Do I need the @ejb.persistence tag if I also have @ejb.pk-field?

Yes.  The pk-field tag just tags this field as being part of the generated
pk class.  The pk-field tag is really used only for compound pks.  What you
really want is:

/**
 * ...
 *
 * @ejb.bean name="XXX" primkey-field="addressId" type="CMP" ...
 */
public abstract class XXXBean ...

  ...

 /*
  * @ejb.interface-method
  * @ejb.persistence
  */
 public abstract Integer getAddressId();

For non-compound primary keys, use the primkey-field attribute of the
@ejb.bean tag.

Michael


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to