Please note, the code I marked up is for a unidirectional 1:N.. and looking back at your original post, you're using a bidirectional.. which means you'll split up the relation information across the 2 classes. But, the rest of the semantics should still be the same






From: "Adam Levine" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: [Xdoclet-user] JBoss + CMR Date: Thu, 24 Jul 2003 10:21:34 -0500

Each Bean should be self-contained. It should not have any get/set references to any fields outside of itself.

ie: PersonBean: get/setPersonId, get/setName

PhoneBean: get/setPhoneId, get/setPhoneType, get/setPhoneNumber


Then in your person bean you'll manage a Collection of Phones


//==================== CMR =================//
/**
* get the phone #s for this person
*
* @ejb.interface-method
* @ejb.value-object
* aggregate="com.interfaces.PhoneValue"
* aggregate-name="Phone"
* members="com.interfaces.PhoneLocal"
* members-name="PhoneValue"
* relation="external"
* type="Collection"
*
* @ejb.relation
* name="person-to-phones"
* role-name="person"
* multiple="yes"
* target-role-name="phones"
* target-ejb="Phone"
*
*
* @jboss.target-relation
* related-pk-field="personId" <-- this is the field to use from the person bean
* fk-column="person_id_fk" <-- which gets put in this column in the phone table
*
*/
public abstract java.util.Collection getPhones();


    /**
     [EMAIL PROTECTED]
     */
   public abstract void setPhones(java.util.Collection phones)


This will cause your tables to be automatically created as such: Person: person_id, person_name Phone: phone_id, phone_type, phone_number, person_id_fk


So, to relate it to SQL: Show all the phone #s for person whose ID is 123

select phone_number
from phone
where person_id_fk = 123

The use, or lack of, the TARGET-xxxx signifies in which direction the relation works -- IOW, where do you place the key, and whose key is it.

I hope that helps. I had a heck of a time working it all out when I started messing with Xdoclet and CMR.


-- adam




From: "Maxime Chevalier" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
Subject: RE: [Xdoclet-user] JBoss + CMR
Date: Thu, 24 Jul 2003 14:56:53 +0200

Thank you,
Indeed I'm storing the FK (called numetbper) in my table Personne.
But if I don't put an @ejb-persistence tag, I have an error because when I
create a Personne the server don't find the FK...

If I let the persistence tag:
It seems there is a conflict between the attributes numetbper (the FK) and
etablissement (the CMR field) during the creation.
How can I manage this

Thanks

-----Message d'origine-----
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] la part de Adam
Levine
Envoy� : mercredi 23 juillet 2003 21:29
� : [EMAIL PROTECTED]
Objet : Re: [Xdoclet-user] JBoss + CMR


If you're storing the FK in your table/class, do not create/manage it with a @ejb-persistence tag




From: "Maxime Chevalier" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: "xdoclet" <[EMAIL PROTECTED]> Subject: [Xdoclet-user] JBoss + CMR Date: Wed, 23 Jul 2003 19:45:06 +0200

Hello,

I try to create CMR between 2 CMP under JBoss: Personne and Etablissement
I manage to deploy and a simple Read-access functions well.
My problem is with a Write Access. My DataBase returns:

 >12:25:11,808 ERROR [STDERR] javax.ejb.CreateException: Could not create
 >entity:java.sql.SQLException: ORA-00957: duplicate column name

The CMR is a 1-N relation:

in Personne:

   /**
   * @ejb.interface-method
   * @ejb.transaction
   *      type = "Required"
   *
   * @ejb.relation
   *      name = "PersonnesDansUnEtablissement"
   *      role-name = "PersonneDansUnEtablissement"
   *      target-role-name = "EtablissementADesPersonnes"
   *
   * @jboss.relation
   *      fk-column = "NUMETBPER"
   *      related-pk-field = "numetb"
   *      fk-constraint = "true"
   */

public abstract Etablissement getEtablissement();

   /**
   * @ejb.interface-method
   */

public abstract void setEtablissement(Etablissement etablissement);

And in Etablissement:

public abstract java.sql.Date getDatemodetb();

    /**
    * @ejb.interface-method
    * @ejb.transaction
    *      type = "Required"
    * @ejb.relation
    *      name = "PersonnesDansUnEtablissement"
    *      role-name = "EtablissementADesPersonnes"
    *      target-role-name = "PersonneDansUnEtablissement"
    *      target-cascade-delete = "no"
    *
    */

public abstract java.util.Collection getPersonne();

   /**
    * @ejb.interface-method
    */

public abstract void setPersonne(java.util.Collection personne);

Does anyone have an idea of the source of the problem ?
Thanks by advance

Maxime



-------------------------------------------------------
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
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus



-------------------------------------------------------
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
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-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
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail




-------------------------------------------------------
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
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail




-------------------------------------------------------
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
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to