CMR Problem
behrangsa Feb 7, 2004 12:22 PMHi
The EJB 2.0 specification [10.3.2] says that: "An entity bean that does not have a local interface can have only unidirectional relationships from itself
to other entity beans. The lack of a local interface prevents other entity beans from having a relationship to it."
I have written a couple of very simple CMP entity beans namely
PersonBean and AddressBean and have established a unidirectional
relationship from PersonBean to AddressBean. The unit deploys
successfuly on JBoss if I write local interfaces for both of the PersonBean
and AddressBean but if I remove the local interface for the PersonBean I
can't deploy the unit anymore and get some errors.
The deployment descriptor is as follows (the unit does not have jboss
specific dds):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'> <ejb-jar> <enterprise-beans> <entity> <display-name>The Person CMP</display-name> <ejb-name>PersonCMP2</ejb-name> <home>org.behrang.cmp.person.PersonHome</home> <remote>org.behrang.cmp.person.RemotePerson</remote> <!--<local-home>org.behrang.cmp.person.LocalPersonHome</local-home> <local>org.behrang.cmp.person.LocalPerson</local>--> <ejb-class>org.behrang.cmp.person.PersonBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>False</reentrant> <abstract-schema-name>person</abstract-schema-name> <cmp-version>2.x</cmp-version> <cmp-field> <field-name>id</field-name> </cmp-field> <cmp-field> <field-name>name</field-name> </cmp-field> <cmp-field> <field-name>familyName</field-name> </cmp-field> <primkey-field>id</primkey-field> <query> <query-method> <method-name>findByName</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </query-method> <ejb-ql> <![CDATA[SELECT OBJECT(o) FROM person as o where o.name = ?1]]> </ejb-ql> </query> </entity> <entity> <display-name>The Address CMP</display-name> <ejb-name>AddressCMP</ejb-name> <home>org.behrang.cmp.address.AddressHome</home> <remote>org.behrang.cmp.address.RemoteAddress</remote> <local-home>org.behrang.cmp.address.LocalAddressHome</local-home> <local>org.behrang.cmp.address.LocalAddress</local> <ejb-class>org.behrang.cmp.address.AddressBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Integer</prim-key-class> <reentrant>False</reentrant> <abstract-schema-name>address</abstract-schema-name> <cmp-version>2.x</cmp-version> <cmp-field> <field-name>id</field-name> </cmp-field> <cmp-field> <field-name>address</field-name> </cmp-field> <primkey-field>id</primkey-field> </entity> </enterprise-beans> <relationships> <ejb-relation> <ejb-relation-name>Person-Address</ejb-relation-name> <ejb-relationship-role> <ejb-relationship-role-name>Person-has-Address</ejb-relationship-role-name> <multiplicity>One</multiplicity> <relationship-role-source> <ejb-name>PersonCMP2</ejb-name> </relationship-role-source> <cmr-field> <cmr-field-name>address</cmr-field-name> </cmr-field> </ejb-relationship-role> <ejb-relationship-role> <ejb-relationship-role-name>Address-has-Person</ejb-relationship-role-name> <multiplicity>One</multiplicity> <relationship-role-source> <ejb-name>AddressCMP</ejb-name> </relationship-role-source> </ejb-relationship-role> </ejb-relation> </relationships> </ejb-jar>