geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Carew" <dcca...@gmail.com>
Subject Re: Openejb-jar and EJB 2.1 CMR Many-Many Example
Date Fri, 20 Apr 2007 15:35:04 GMT
Here's a simplified version of the DB schema I used for a many to many
relationship between  CMP Entity beans called Account and Customer

create table customer
(
  customerid integer not null,
  title character(3) not null,
  firstname varchar(30) not null,
  lastname  varchar(30) not null,
  pin character(4) not null,
  primary key (customerid)
);


create table account
(
   accid character(11) not null,
   balance decimal(8,2) not null,
   interest decimal(5,3),
   type varchar(60) not null,
   primary key(accid)
);


create table custacct
(
   customerid integer not null,
   accid character(11) not null,
   primary key(customerid, accid),
   foreign key(customerid) references customer ON DELETE RESTRICT,
   foreign key(accid) references account ON DELETE RESTRICT
);


Here's the corresponding snippet from my openejb-jar.xml file

  <relationships>

                <ejb-relation>
                  <ejb-relation-name>Accounts-Customers</ejb-relation-name>
                   <many-to-many-table-name>
                         custacct
                   </many-to-many-table-name>


                   <ejb-relationship-role>
                      <relationship-role-source>
                         <ejb-name>Account</ejb-name>
                       </relationship-role-source>
                       <cmr-field>
                         <cmr-field-name>customers</cmr-field-name>
                       </cmr-field>
                       <role-mapping>
                       <cmr-field-mapping>
                       <key-column>accid</key-column>
                        <foreign-key-column>accid</foreign-key-column>
                       </cmr-field-mapping>
                     </role-mapping>
                  </ejb-relationship-role>

                   <ejb-relationship-role>
                    <relationship-role-source>
                       <ejb-name>Customer</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                       <cmr-field-name>accounts</cmr-field-name>
                     </cmr-field>
                    <role-mapping>
                       <cmr-field-mapping>
                              <key-column>customerid</key-column>
                        <foreign-key-column>customerid</foreign-key-column>
                       </cmr-field-mapping>
                       </role-mapping>
                     </ejb-relationship-role>
                 </ejb-relation>

         </relationships>

On 4/20/07, Mark Aufdencamp <mark@aufdencamp.com> wrote:
>
> Hi All,
>
>  I'm continuing my studies and have successfully deployed CMP Entity Beans
> with some rudimentary QL.  I'm now working on come container manged
> relationships (CMR).  I can't seem to find much documentation on the
> appropriate mapping of the ejb-jar relationships to the openejb-jar
> definitions.  Can someone provide some direction to documentation on the
> openejb-jar mappings.  In particulare, I'm working on a Many-To-Many
> relationship.  I have a 3rd NF Table structure and the Entity Beans, just
> need that last bit of info on the openejb-jar mappings.
>
> Thanks,
>
> Mark Aufdencamp
> Mark@Aufdencamp.com
>
>
>
>

Mime
View raw message