I finaly got it right..
i had an old version of xdoclet, so i upgraded to 1.2, then it generated
my relation-table in jboss-jdbc.xml .......
it then sayd that i needed keyfelds on both sides, so i added:
* @jboss.relation
* related-pk-field="user_key"
* fk-column="userKey"
user_key is the primary key in Users table
userKey is the column in in my relation table
so my source looks:
/**
* @ejb.interface-method
* @jboss.relation-mapping
* style="relation-table"
* @ejb.relation
* name="MailMessages-toAccount"
* role-name="MailMessages-Has-toAccount"
* target-ejb="Accounts"
* target-role-name="toAccount-belongs_to-MailMessages"
* target-cascade-delete="yes"
* @jboss.target-relation
* related-pk-field="messageKey"
* fk-column="messageKey"
* @jboss.relation
* related-pk-field="account_key"
* fk-column="accountKey"
* @jboss.relation-table
* table-name="MailMessages_toAccounts"
* create-table="true"
* remove-table="true"
*/
public abstract Collection getToAccounts();
Thanks and regards, David
On Thu, 2003-10-02 at 16:43, David Nielsen wrote:
> Why the fu.....
> does xdoclet not se my
> * @jboss.relation-mapping style="relation-table"
> and
> * @jboss.relation-table
> * table-name="MailMessages_toUsers"
>
> and still generate <foreign-key-mapping/>
> in jbosscmp-jdbc.xml
>
> does they have to be in a correct order or... ???
>
> On Thu, 2003-10-02 at 11:40, David Nielsen wrote:
> > Oki..
> >
> > The Users Table has:
> >
> > user_key (primary key)
> > username
> > password
> > date_add
> > date_avail
> > date_expire
> > status_id (ref to a status_ids table 1:1)
> >
> > And the MailMessages table
> >
> > messageKey
> > subject
> > fromUser (Here i need to ref to 1 user in Users table 1:1)
> > toUsers (Here I need to have a Collection of Users 1:N)
> > messageType (ref to messagetypes table 1:1)
> > parrentmessagekey (ref to other mailmessage 1:1)
> > projecttaskkey (ref to projecttasks table 1:1)
> > text
> >
> > The names is a little.....
> > the Users table is created by hand long ago, and the MailMessages is
> > created by jboss when deployed first time. its empty so no matter if i
> > have to drop it, but no dropping the Users table.
> >
> >
> > In the MailMessagesBean.java i have:
> >
> >
> >
> > /**
> > * @ejb.interface-method
> > * @ejb.relation
> > * name="MailMessages-toUsers"
> > * role-name="MailMessages-Has-toUsers"
> > * target-ejb="Users"
> > * target-role-name="toUsers-belongs-to-MailMessages"
> > * target-cascade-delete="yes"
> > * @jboss.target-relation
> > * related-pk-field="messageKey"
> > * fk-column="msgKey"
> > * @jboss.relation-table
> > * table-name="MailMessages_toUsers"
> > */
> > public abstract Collection getToUsers();
> > /**
> > * @ejb:interface-method view-type="local"
> > */
> > public abstract void setToUsers(Collection toUsers);
> >
> >
> >
> >
> > when i deploy jboss doesnt create the MailMessages_toUsers table,
> > Xdoclet generates these deployment descriptors:
> > It generates <foreign-key-mapping/> in jbosscmp-jdbc.xml and not
> > relation-table, i even tried
> > @jboss.relation-mapping style="relation-table", still no relation-table
> > in jbosscmp-jdbc.xml
> >
> >
> >
> > ejb-jar.xml:
> >
> > <ejb-relation >
> > <ejb-relation-name>MailMessages-toUsers</ejb-relation-name>
> > <!-- unidirectional -->
> > <ejb-relationship-role >
> >
> > <ejb-relationship-role-name>MailMessages-Has-toUsers</ejb-relationship-role-name>
> > <multiplicity>One</multiplicity>
> > <relationship-role-source >
> > <ejb-name>MailMessages</ejb-name>
> > </relationship-role-source>
> > <cmr-field >
> > <cmr-field-name>toUsers</cmr-field-name>
> > <cmr-field-type>java.util.Collection</cmr-field-type>
> > </cmr-field>
> > </ejb-relationship-role>
> > <ejb-relationship-role >
> >
> > <ejb-relationship-role-name>toUsers-belongs_to-MailMessages</ejb-relationship-role-name>
> > <multiplicity>Many</multiplicity>
> > <cascade-delete/>
> > <relationship-role-source >
> > <ejb-name>Users</ejb-name>
> > </relationship-role-source>
> > </ejb-relationship-role>
> > </ejb-relation>
> >
> >
> > jbosscmp-jdbc.xml:
> >
> > <ejb-relation>
> > <ejb-relation-name>MailMessages-toUsers</ejb-relation-name>
> > <foreign-key-mapping/>
> > <ejb-relationship-role>
> >
> > <ejb-relationship-role-name>MailMessages-Has-toUsers</ejb-relationship-role-name>
> > <key-fields>
> > <key-field>
> > <field-name>messageKey</field-name>
> > <column-name>msgKey</column-name>
> > </key-field>
> > </key-fields>
> > </ejb-relationship-role>
> > <ejb-relationship-role>
> >
> > <ejb-relationship-role-name>toUsers-belongs_to-MailMessages</ejb-relationship-role-name>
> > <key-fields/>
> > </ejb-relationship-role>
> > </ejb-relation>
> >
> >
> >
> > my build.xml has:
> >
> > <localinterface/>
> > <homeinterface />
> > <localhomeinterface/>
> > <remoteinterface/>
> > <entitypk/>
> > <deploymentdescriptordestdir="${ejb.build.dir}/META-INF"/>
> >
> > and tryed the <entitycmp/>, whats that for ??
> >
> >
> >
> >
> > Regards David
> >
> >
> >
> >
> > On Wed, 2003-10-01 at 23:25, Harkness, David wrote:
> > > Trying to clarify...
> > >
> > > David Nielsen <mailto:[EMAIL PROTECTED]> once said:
> > > > /**
> > > > * @ejb:interface-method
> > > > * @ejb:relation
> > > > * name="MailMessages-toUser"
> > > > * role-name="MailMessages-Has-toToUser"
> > > > * target-ejb="Users"
> > > > * target-role-name="toUser-belongs_to-MailMessages"
> > > > * target-cascade-delete="yes"
> > > > * @jboss:target-relation
> > > > * related-pk-field="messageKey"
> > > > * fk-column="messageKey"
> > > > * @jboss:relation-table
> > > > * table-name="MailMessages_toUsers"
> > > > * create-table="true"
> > > > * remove-table="true"
> > > > ...
> > > > jboss creates the mailmessages + the users table but no
> > > > mailmessages_tousers table, and there now are a column (messagekey) in
> > >
> > > > users table.
> > >
> > > This is a unidirectional 1:N relation, correct? I ask because you don't
> > > need a separate relation table to model 1:N -- only for N:M. And if it's
> > > N:M, "toUser" is actually a Collection, and the role-name would be
> > > "MailMessages-Have-Many-toUsers".
> > >
> > > Though this shouldn't matter, the role-name has a typo. It should be
> > > "MailMessages-Has-toUser", not "toToUser". Regardless, can you provide a
> > > bit more detail here, perhaps including the schema and a description of
> > > the relation itself. I'm finding it difficult to apply my intuition when
> > > the names don't match up with my expectations.
> > >
> > > For example, you use "MailMessages" and "Users", yet I expect that they
> > > actually represent single objects. A "Users" is a single user, and each
> > > may have zero-or-more "MailMessages"s. I realize, though, that many
> > > people name their DB tables with plurals (users_t vs. user_t). I just
> > > want to make sure so we can help you better.
> > >
> > > David Harkness
> > > Sr. Software Engineer
> > > Sony Pictures Digital Networks
> > > (310) 482-4756
> > >
> > >
> > > -------------------------------------------------------
> > > 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
> >
>
>
>
> -------------------------------------------------------
> 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