I hate to answer my own questions, but this was the solution.

If you create a bidirectional relationship, you need to use the same name in
your relationship

Fund Bean
*  @ejb.relation
*      name="instrument-instrumentCodes"

InstrumentCodes
* @ejb.relation
*      name="instrument-instrumentCodes"

That's how easy this was....


Jan


-----Original Message-----
From: kiuma [mailto:[EMAIL PROTECTED] 
Sent: zaterdag 15 maart 2003 10:20
To: [EMAIL PROTECTED]
Subject: Re: [Xdoclet-user] CMR relations driving me crazy


Casteels Jan wrote:

>Hi All,
>
>Please help me out, this is driving me insane.
>I have made a 1-N relationship but for a strange reason the insert 
>statement in instrumentcodes has 2 times the FK. I think it is because 
>I did something wrong with my Xdoclet specification of relationships.
>
>
>/** generated by Weblogic ejbc compiler **/ 
>            as[0] = "INSERT INTO INSTRUMENT_CODES (IC_UID, 
>ROW_VERSION_NR, CODE_ID, IC_TYP_CD, INS_UID_FK, INS_UID_FK) VALUES (?, 
>?, ?, ?, ?, ?)";
>/** end generated by Weblogic ejbc compiler **/
>
>I included the deploymentdescriptor of Weblogic at the bottom,
>
>I want to put a relation 1*N bidirectional relationship
>
>
>
>Fund   -------*   InstrumentCodes
>
>
>Fund Bean
>
>Start
>/**
> * Concrete entity bean that implements the Fund interface.
> *
> *
> * @ejb.bean generate="true"
> *           name="Fund"
> *           type="CMP"
> *           view-type="local"
> *           local-jndi-name="com.capco.example.instruments.server.Fund"
> *           schema="Funds"
> *
> ....
> *
>  */
>
>
>  /**
>     * @ejb.relation
>     *      name="instrument-instrumentCodes"
>     *      role-name="instrument-has-instrumentCodes"
>     *      target-ejb="InstrumentCode"
>     *      target-role-name="instrumentCode-belongs_to-Instrument"
>     *      target-cascade-delete="no"
>     *
>     * @weblogic.target-column-map
>     *        foreign-key-column="INS_UID"
>     *
>     */
>    public abstract Collection getInstrumentCodes();
>
>    public abstract void setInstrumentCodes(Collection 
> aInstrumentCodes);
>
>
>InstrumentCodes bean
>
>  /**
>   * InstrumentCodes
>   *
>   * @ejb.bean generate="true"
>   *           name="InstrumentCode"
>   *           type="CMP"
>   *           view-type="local"
>   *           local-jndi-
>name="com.capco.example.instruments.server.InstrumentCode"
>   *           schema="InstrumentCode"
>    .....
>
>
>
>   /**
>     * @return
>     *
>     * @ejb.interface-method view-type="local"
>     * @ejb.relation
>     *      name="instrumentCode-instrument"
>     *      role-name="instrumentCode-refers_to-instrument"
>     *      target-ejb="Fund"
>     *      target-role-name="instrument-is_refered_by-instrumentCode"
>     *      target-multiple="no"
>     * @weblogic.column-map
>     *      foreign-key-column="INS_UID_FK"
>     *
>     *
>     */
>    public abstract Fund getInstrument();
>
>    /**
>     *
>     *
>     ** @ejb.interface-method view-type="local"
>     */
>    public abstract void setInstrument(Fund aInstrument);
>
>
>
>  <weblogic-rdbms-relation>
>      <relation-name>instrumentCode-instrument</relation-name>
>      <weblogic-relationship-role>
>
> 
><relationship-role-name>instrumentCode-refers_to-instrument</relationsh
>ip-ro
>le-name>
>         <relationship-role-map>
>         <column-map>
>            <foreign-key-column>INS_UID_FK</foreign-key-column>
>            <key-column>INS_UID</key-column>
>         </column-map>
>         </relationship-role-map>
>      </weblogic-relationship-role>
>   </weblogic-rdbms-relation>
>   <weblogic-rdbms-relation>
>      <relation-name>instrument-instrumentCodes</relation-name>
>      <weblogic-relationship-role>
>
> 
><relationship-role-name>instrumentCode-belongs_to-Instrument</relations
>hip-r
>ole-name>
>         <relationship-role-map>
>         <column-map>
>            <foreign-key-column>INS_UID_FK</foreign-key-column>
>            <key-column>INS_UID</key-column>
>         </column-map>
>         </relationship-role-map>
>      </weblogic-relationship-role>
>   </weblogic-rdbms-relation>
>
>
>
>Jan Casteels
>Tel : +32497518897
>www.capco.com
>
>
>
>  
>
>-----------------------------------------------------------------------
>-
>
>***********************************************************************
>*
>The information in this email is confidential and is intended solely
>for the addressee(s).
>Access to this email by anyone else is unauthorised. If you are not
>an intended recipient, please notify the sender of this email 
>immediately. You should not copy, use or disseminate the 
>information contained in the email.
>Any views expressed in this message are those of the individual
>sender, except where the sender specifically states them to be
>the views of Capco.
>
>http://www.capco.com
>***********************************************************************
>
>  
>
Hi Jan 

* @weblogic.target-column-map
*        foreign-key-column="INS_UID"

Target is used to refer to another bean (target) so 4 example I have a 
SpecialityBean and a ActivityBean in a one-to-many relation
specialities[code, SpecName,...]
-SpecialityBean-
...
/**
* @ejb.relation
*    name="speciality-activity"
*    role-name="speciality-has-activities"
* @jboss.relation-mapping
*    style="foreign-key"
*/
public abstract Colection getActivities()

activities[code, actName, spec_code, ...]
-ActivityBean-
....
/**
* @ejb.relation
*    name="speciality-activity"
*    role-name="activity-has-speciality"
* @jboss.relation-mapping
*    style="foreign-key"
* @jboss.relation
*    fk-constraint="true"
*    fk-column="spec_code"
*    related-pk-field="code"
*/

I hope this helps!

Ciao,
kiuma



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user
************************************************************************
The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, please notify the sender of this email 
immediately. You should not copy, use or disseminate the 
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com
***********************************************************************

Reply via email to