You need to adjust your tags. It sounds like you only have 2 tables and
not a 3rd, mapping table. Since JBOSS is thinking you are using relation
table mapping, you need to add a jboss tag to use reference mapping or
just totally re-do your @ejb tags to make them bi-directional, not
unidirectional. You could put the name="MailMessages-toUser" on both
sides of the relation and drop the target-ejb target role tags and
xdoclet will set everything up for you pretty nicely. 

Also, check your generated xml deployment file to see if the tags you
have setup are doing a many to many relation instead of one to many like
you want. Many to many relations will cause jboss to look for a mapping
table.


Here is how I would set it up if I were doing it:

/**
* @ejb.interface-method view-type="local"
* @ejb:relation
*   name="MailMessages-toUser"
*   role-name="MailMessages-Has-Many_toUsers"
*/
public abstract Collection getToUsers();
/**
[EMAIL PROTECTED]:interface-method view-type="local"
*/
public abstract void setToUsers(Collection toUsers);

THEN.. ON THE MANY SIDE.... HAVE THE FOLLOWING:

/**
 * @ejb.interface-method view-type="local"
 * 
 *
 * @ejb:relation
 *   name="MailMessages-toUser"
 *   role-name="MailMessages-Has-Many_toUsers"
 *
 * @jboss.relation
 *  fk-column = "ToUser"
 *  related-pk-field = "user_key"
 */
public abstract ToUsersLocal getToUser();

Notice that the fk-column "ToUser" matches the many side - you will need
a field in the manyside table that matches it. The related-pk-field is
the column name in the table on the one side.

This is a bi-directional, 1 to many relationship. JBoss will not look
for a relation mapping table.







On Wed, 2003-10-01 at 06:42, David Nielsen wrote:
> I have a problem with my relatonship:
> 
> i have a table called MailMessages and a table called Users.
> 
> in my MailMessages i have a getToUsers which is a collection of Users
> which i send messages.
> 
> so i created:
> 
> /**
> * @ejb.interface-method
> * @ejb:relation
> *   name="MailMessages-toUser"
> *   role-name="MailMessages-Has-Many_toUsers"
> *   target-ejb="Users"
> *   target-role-name="toUser-belongs_to-MailMessages"
> *   target-cascade-delete="no"
> *   target-multiple="yes"
> * @jboss.relation
> *  fk-column = "toUsers"
> *  related-pk-field = "user_key"
> *  fk-constraint = "true"
> */
> public abstract Collection getToUsers();
> /**
> [EMAIL PROTECTED]:interface-method view-type="local"
> */
> public abstract void setToUsers(Collection toUsers);
> 
> 
> but jboos keep saying:
> 
> Both roles of a relation-table mapped relationship must have key fields:
> ejb-relation-name=MailMessages-toUser
> 
> dont thay have that ? whats giong wrong
> 
> i have a 1-1 relation working, the ony diference i made is that i use a
> Collection instead of UsersLocal interface
> 
> Regard David Nielsen
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user



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

Reply via email to