I have 2 cmp entity beans, ResourceBean and RentalBean that I want to have in a 
one-to-many whereby one Resource has many Rentals, each Rental is for one 
Resource. The RentalBean constructor requires an instance of the Local int. of 
Resource which I then use in a call to Rental.setResource. I was expecting this 
to update both sides of the rel'ship, ie add an element to Resource.rentals but 
this doesn't happen. There is binary content in the RENTALBEAN.RESOURCE column 
in hypersonic but RESOURCEBEAN.RENTALS remains null. When the tables are 
created an extra column is added to the RENTALBEAN table called 
RESOURCEBEAN_RENTALS which is always null and there is no extra column added to 
the RESOURCEBEAN table. This is my ejb-jar.xml:


  | <?xml version="1.0"?>
  | <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise 
JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd";>
  | 
  | <ejb-jar>
  | 
  |    <display-name>swm22</display-name>
  | 
  |    <description>
  |         </description>
  | 
  |    <enterprise-beans>
  |       <entity>
  |          <description>Resource component</description>
  |          <display-name>ResourceBean</display-name>
  |          <ejb-name>ResourceBean</ejb-name>
  |          <local-home>swm22.ejb.LocalResourceHome</local-home>
  |          <local>swm22.ejb.LocalResource</local>
  |          <ejb-class>swm22.ejb.ResourceBean</ejb-class>
  |          <persistence-type>Container</persistence-type>
  |      <cmp-version>2.x</cmp-version>
  |      <abstract-schema-name>ResourceBean</abstract-schema-name>
  |          <prim-key-class>swm22.ejb.ResourcePK</prim-key-class>
  |          <reentrant>False</reentrant>
  |          <cmp-field><field-name>resourceId</field-name></cmp-field>
  |          <cmp-field><field-name>name</field-name></cmp-field>
  |          <cmp-field><field-name>description</field-name></cmp-field>
  |          <cmp-field><field-name>rentals</field-name></cmp-field>
  |          <cmp-field><field-name>category</field-name></cmp-field>
  |          <cmp-field><field-name>active</field-name></cmp-field>
  |      <query>
  |          <description>Get whole collection of Resources</description>
  |              <query-method>
  |                  <method-name>findAll</method-name>
  |           <method-params/>
  |              </query-method>
  |              <ejb-ql>Select OBJECT(r) From ResourceBean r</ejb-ql>
  |          </query>
  |      <query>
  |          <description>Get a resource by name</description>
  |              <query-method>
  |                  <method-name>findByName</method-name>
  |                     <method-params>
  |                         <method-param>java.lang.String</method-param>
  |                     </method-params>
  |              </query-method>
  |              <ejb-ql>Select OBJECT(r) From ResourceBean r where r.name = 
?1</ejb-ql>
  |          </query>
  |       </entity>
  |       
  |       <entity>
  |          <description>Rental component</description>
  |          <display-name>RentalBean</display-name>
  |          <ejb-name>RentalBean</ejb-name>
  |          <local-home>swm22.ejb.LocalRentalHome</local-home>
  |          <local>swm22.ejb.LocalRental</local>
  |          <ejb-class>swm22.ejb.RentalBean</ejb-class>
  |          <persistence-type>Container</persistence-type>
  |      <cmp-version>2.x</cmp-version>
  |      <abstract-schema-name>RentalBean</abstract-schema-name>
  |          <prim-key-class>swm22.ejb.RentalPK</prim-key-class>
  |          <reentrant>False</reentrant>
  |          <cmp-field><field-name>rentalId</field-name></cmp-field>
  |          <cmp-field><field-name>startDate</field-name></cmp-field>
  |          <cmp-field><field-name>endDate</field-name></cmp-field>
  |          <cmp-field><field-name>returnDate</field-name></cmp-field>
  |          <cmp-field><field-name>resource</field-name></cmp-field>
  |      <query>
  |          <description>Get whole collection of Rental</description>
  |              <query-method>
  |                  <method-name>findAll</method-name>
  |           <method-params/>
  |              </query-method>
  |              <ejb-ql>Select OBJECT(r) From RentalBean r</ejb-ql>
  |          </query>
  |       </entity>
  |         
  |       <session>
  |             <ejb-name>ResourceRentalMgrBean</ejb-name>
  |             <home>swm22.ejb.ResourceRentalMgrHome</home>
  |             <remote>swm22.ejb.ResourceRentalMgr</remote>
  |             <ejb-class>swm22.ejb.ResourceRentalMgrBean</ejb-class>
  |             <session-type>Stateless</session-type>
  |             <transaction-type>Container</transaction-type>
  |             <ejb-local-ref>
  |                 <ejb-ref-name>ejb/ResourceBean</ejb-ref-name>
  |                 <ejb-ref-type>Entity</ejb-ref-type>
  |                 <local-home>swm22.ejb.LocalResourceHome</local-home>
  |                 <local>swm22.ejb.LocalResource</local>
  |                 <ejb-link>ResourceBean</ejb-link>
  |             </ejb-local-ref>
  |             <ejb-local-ref>
  |                 <ejb-ref-name>ejb/RentalBean</ejb-ref-name>
  |                 <ejb-ref-type>Entity</ejb-ref-type>
  |                 <local-home>swm22.ejb.LocalRentalHome</local-home>
  |                 <local>swm22.ejb.LocalRental</local>
  |                 <ejb-link>RentalBean</ejb-link>
  |             </ejb-local-ref>
  |             <security-identity>
  |                 <use-caller-identity/>
  |             </security-identity>
  |         </session>
  |       
  |    </enterprise-beans>
  | 
  |    <relationships>
  |    
  |         <ejb-relation>
  |             <ejb-relation-name>ResourceRental</ejb-relation-name>
  |             <ejb-relationship-role>
  |                 
<ejb-relationship-role-name>ResourceHasRentals</ejb-relationship-role-name>
  |                 <multiplicity>One</multiplicity>
  |                 <relationship-role-source>
  |                     <ejb-name>ResourceBean</ejb-name>
  |                 </relationship-role-source>
  |                 <cmr-field>
  |                     <cmr-field-name>rentals</cmr-field-name>
  |                     <cmr-field-type>java.util.Collection</cmr-field-type>
  |                 </cmr-field>
  |             </ejb-relationship-role>
  |             <ejb-relationship-role>
  |               
<ejb-relationship-role-name>RentalForResource</ejb-relationship-role-name>
  |                 <multiplicity>Many</multiplicity>
  |                 <relationship-role-source>
  |                     <ejb-name>RentalBean</ejb-name>
  |                 </relationship-role-source>
  |                 <cmp-field>
  |                     <cmp-field-name>resource</cmp-field-name>
  |                     <cmp-field-type>swm22.ejb.LocalResource</cmp-field-type>
  |                 </cmp-field>
  |             </ejb-relationship-role>
  |         </ejb-relation>
  |         
  |     </relationships>
  |     
  |    <assembly-descriptor>
  |       <container-transaction>
  |          <method>
  |             <ejb-name>ResourceBean</ejb-name>
  |             <method-name>*</method-name>
  |          </method>
  |          <trans-attribute>Supports</trans-attribute>
  |       </container-transaction>
  |       <container-transaction>
  |          <method>
  |             <ejb-name>RentalBean</ejb-name>
  |             <method-name>*</method-name>
  |          </method>
  |          <trans-attribute>Supports</trans-attribute>
  |       </container-transaction>
  |       <container-transaction>
  |          <method>
  |             <ejb-name>ResourceRentalMgrBean</ejb-name>
  |             <method-name>*</method-name>
  |          </method>
  |          <trans-attribute>Supports</trans-attribute>
  |       </container-transaction>
  |       <security-role>
  |          <role-name>users</role-name>
  |       </security-role>
  |    </assembly-descriptor>
  | 
  | </ejb-jar>
  |  

and in jbosscmp-jdbc.xml I have

  |  <enterprise-beans>
  |     
  |         <entity>
  |             <ejb-name>RentalBean</ejb-name>
  |             ...
  |             <cmp-field>
  |                 <field-name>resource</field-name>
  |                 <column-name>RESOURCE</column-name>
  |             </cmp-field>
  |         </entity>
  |         
  |         <entity>
  |             <ejb-name>ResourceBean</ejb-name>
  |             ...
  |             <cmp-field>
  |                 <field-name>rentals</field-name>
  |                 <column-name>RENTALS</column-name>
  |             </cmp-field> 
  |             ...
  |         </entity>
  | 
  |     </enterprise-beans>
  | 

where am I goin wrong?

Thanks in advance

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3881096#3881096

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3881096


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to