I don't see why you need EventPK - xxxPK is generated by xdoclet for
composite keys, but your EventPK just takes an integer.

Also, I don't see the xdoclet tags in Event bean to indicate what cmp
fields form the pk.

In my experience, jboss doesn't support relation where the fk is part of
a composite primary key.

Are the ejb-jar.xml and jbosscmp-jdbc.xml as you expect/want?

Martin

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sunny Bro
Sent: 23 March 2004 16:54
To: [EMAIL PROTECTED]
Subject: [Xdoclet-user] composite key relations with jboss

hi, i'm trying to get basic relations to work with jboss 3.2.3 using 
composite keys but seem to be messing up somewhere.


I'm using the following structure:

Table user_in_group (2 fields only) :
user_id (part of composite primary key)
group_id (part of composite primary key)

Table events:
event_id (primary key)
user_id (foreign key to user_id in user_in_group table)
group_id(fk to group_id)
event_name
...



in UserInGroup Bean i have

   /**
    * @ejb.pk-field
        * @ejb.persistence table-name="UserInGroup"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="user_id"
    */
   public abstract java.lang.Integer getUserId();
   /**
        * @ejb.persistence table-name="UserInGroup"
        * @ejb.interface-method view-type="local"
        * @jboss.column-name name="user_id"
    */
   public abstract void setUserId(java.lang.Integer user_id);


   /**
        * @ejb.pk-field
        * @ejb.persistence table-name="UserInGroup"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="group_id"
    */
   public abstract java.lang.Integer getGroupId();
    /**
        * @ejb.persistence table-name="UserInGroup"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="group_id"
    */
   public abstract void setGroupId(java.lang.Integer group_id);


and in Event Bean

    /**
        * @ejb.persistence table-name="events"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="user_id"
    */
   public abstract Integer getUserId();
   /**
        * @ejb.persistence table-name="events"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="user_id"
    */
   public abstract void setUserId(Integer user_id);


   /**
        * @ejb.persistence table-name="events"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="group_id"
    */
   public abstract java.lang.Integer getGroupId();
   /**
        * @ejb.persistence table-name="events"
        * @ejb.interface-method view-type="both"
        * @jboss.column-name name="group_id"
    */
   public abstract void setGroupId(Integer group_id);


The relation is defined in Event bean as

   /**
   * @ejb:interface-method view-type="both"
   * @ejb:transaction type="Required"
   *
   * @ejb:relation
   *    name="Event-UIG"
   *    role-name="Event-UIG-role"
   *    target-ejb="UserInGroup"
   *    target-role-name="eventsOf-UIG"
   *    target-multiple="no"
   *
   * @jboss:relation
   *    fk-column="userId"
   *    related-pk-field="userId"
   * @jboss:relation
   *    fk-column="groupId"
   *    related-pk-field="groupId"
   */
   public abstract scheduler.interfaces.UserInGroupLocal getUIGRecord();
   /**
   * @ejb:interface-method view-type="local"
   */
   public abstract void
setUIGRecord(scheduler.interfaces.UserInGroupLocal 
uig);


The method interface is generated to the Event and EventLocal files.



To confirm that there is a record available, i performed the sql search

select u.* from user_in_group u, events e
where u.user_id = e.user_id
and u.group_id = e.group_id
and e.event_id=1;

and was able to retrieve one record.


But when i try to use the following relation,

   Event event = eventHome.findByPrimaryKey(new EventPK(new
Integer(1)));
   scheduler.interfaces.UserInGroupLocal uigRecord =
event.getUIGRecord();

i get "javax.ejb.ObjectNotFoundException: No such entity!" on the second

line using the relation.

Thanks for your help,

Regards,
sunil.

_________________________________________________________________
Get tax tips, tools and access to IRS forms - all in one place at MSN
Money! 
http://moneycentral.msn.com/tax/home.asp



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to