If you mean mapping foreign key fields to primary key fields, yes, it is possible. Just specify the same column names for foreign and primary keys.
If you want UNIQUE, you have to do it yourself, JBoss does not generate it.


alex

Milen Dyankov wrote:
Hi all,

this could be more EJB than JBoss related question, but since I'm using
JBoss I thought I would ask for help here.

Lets say I have 3 beans as shown below:

===== SalesBean =====
  /**
   *  @...
   */
  public abstract class SalesBean implements javax.ejb.EntityBean {
    //[ ... snip ... ]

     *  @ejb.pk-field
     *  @...
     */
    public abstract String getId ();
    public abstract void setId (String id);

     *  @ejb.relation
     *      name = "Sales-Customer"
     *      role-name = "Sales-for-Customer"
     *      cascade-delete = "yes"
     *  @...
     */
    public abstract CustomerLocal getCustomer ();
    public abstract void setCustomer (CustomerLocal customer);

    /**
     *  @ejb.relation
     *      name = "Sales-Product"
     *      role-name = "Sales-for-Product"
     *      cascade-delete = "yes"
     *  @...
     */
    public abstract ProductLocal getProduct ();
    public abstract void setProduct (ProductLocal product);

    /**
     *  @...
     */
    public abstract Integer getAmount ();
    public abstract void setAmount (Integer licenceFieldPermissions);
    //[ ... snip ... ]


===== CustomerBean ===== /** * @... */ public abstract class CustomerBean implements javax.ejb.EntityBean { //[ ... snip ... ]

    /**
     *  @ejb.relation
     *      name = "Sales-Customer"
     *      role-name = "Customer-has-Sales"
     *  @...
     */
    public abstract Collection getSales ();
    public abstract void setSales (Collection sales);
    //[ ... snip ... ]


===== ProductBean ===== /** * @... */ public abstract class ProductBean implements javax.ejb.EntityBean { //[ ... snip ... ]

   /**
     *  @ejb.relation
     *      name = "Sales-Product"
     *      role-name = "Product-has-Sales"
     *  @...
     */
    public abstract Collection getSales ();
    public abstract void setSales (Collection sales);
    //[ ... snip ... ]


=========================


Relationship works just fine and JBoss creates "customer" and "product" fields in "Sales" table. Now what I would like to do is
PRIMARY KEY ('custommer', 'product')
or at least
UNIQUE ('custommer', 'product')


Is this possible?

If "custommer" and "product" are not <cmp-field>'s XDoclet seems to ignore the "@ejb.pk-field" tag for "getCustomers" and "getProduct". If I make them <cmp-field>'s then the relationship does not work.


All I need is to make sure that a customer "X" can have only one record in table "Sales" for product "Y". Then I would get rid of "id" in "Sales" which I don't need at all.



Best regards, Milen Dyankov




------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user




------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to