0 Replies Latest reply on Nov 15, 2003 5:09 PM by kpdcp

    Jboss/Xdoclet/Lomboz Bug w/CMR???

    kpdcp Newbie

      I'm trying to set up a simple one to many unidirectional relationship using eclipse, jboss, xdoclet, and lomboz. I keep getting "foreign key constraint is not allowed for this type of datastore". I'm not sure if this is some kind of jboss bug or what, but it seems like it ought to work.

      Can anyone please clarify if this is a bug, or what I'm doing wrong? I'd like to at least know if this is a jboss bug so I can quit wasting my time trying to figure it out.

      Here's my PersonBean code for the many side of the relationship:

      /**
      * @return the company the person belongs to
      *
      * @ejb.interface-method
      *
      * @ejb.relation
      * name="Person-Company"
      * role-name="Person-belongs-to-Company"
      * target-ejb="Company"
      * target-role-name="Company-has-many-Persons"
      * target-multiple="yes"
      * @jboss.relation
      * fk-constraint="true"
      * fk-column="COMPANY"
      * related-pk-field="id"
      *
      */
      public abstract CompanyLocal getCompany();

      /**
      * Sets the new company for the person
      *
      * @param CompanyLocal the new company
      *
      * @ejb.interface-method
      * tview-type="local"
      *
      */
      public abstract void setCompany(CompanyLocal companyLocal);

      ========================
      Here's the jboss.xml
      ========================
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">



      <unauthenticated-principal>nobody</unauthenticated-principal>

      <enterprise-beans>

      <!--
      To add beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called jboss-beans.xml that contains
      the , and <message-driven></message-driven>
      markup for those beans.
      -->


      <ejb-name>Company</ejb-name>
      <jndi-name>CompanyBean</jndi-name>
      <local-jndi-name>CompanyLocal</local-jndi-name>



      <ejb-name>Person</ejb-name>
      <jndi-name>PersonBean</jndi-name>
      <local-jndi-name>PersonLocal</local-jndi-name>




      <ejb-name>LombozSession</ejb-name>
      <jndi-name>LombozSessionBean</jndi-name>
      <local-jndi-name>LombozSessionLocal</local-jndi-name>



      <ejb-name>Access</ejb-name>
      <jndi-name>AccessBean</jndi-name>
      <local-jndi-name>AccessLocal</local-jndi-name>



      </enterprise-beans>

      <resource-managers>
      </resource-managers>



      ==================
      Here's the ejb-jar.xml
      ==================
      <?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 >

      <![CDATA[No Description.]]>
      <display-name>Generated by XDoclet</display-name>

      <enterprise-beans>

      <!-- Session Beans -->

      <![CDATA[]]>

      <ejb-name>LombozSession</ejb-name>

      com.paynetech.session.LombozSessionHome
      com.paynetech.session.LombozSession
      <local-home>com.paynetech.session.LombozSessionLocalHome</local-home>
      com.paynetech.session.LombozSessionLocal
      <ejb-class>com.paynetech.session.LombozSessionSession</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>




      <![CDATA[]]>

      <ejb-name>Access</ejb-name>

      com.paynetech.session.AccessHome
      com.paynetech.session.Access
      <local-home>com.paynetech.session.AccessLocalHome</local-home>
      com.paynetech.session.AccessLocal
      <ejb-class>com.paynetech.session.AccessSession</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>



      <!--
      To add session beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called session-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Entity Beans -->

      <![CDATA[]]>

      <ejb-name>Company</ejb-name>

      com.paynetech.cmp.CompanyHome
      com.paynetech.cmp.Company
      <local-home>com.paynetech.cmp.CompanyLocalHome</local-home>
      com.paynetech.cmp.CompanyLocal

      <ejb-class>com.paynetech.cmp.CompanyCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>mySchema</abstract-schema-name>
      <cmp-field >
      <![CDATA[Returns the id]]>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the name]]>
      <field-name>name</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>


      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT OBJECT(a) FROM mySchema as a]]></ejb-ql>

      <!-- Write a file named ejb-finders-CompanyBean.xml if you want to define extra finders. -->



      <![CDATA[]]>

      <ejb-name>Person</ejb-name>

      com.paynetech.cmp.PersonHome
      com.paynetech.cmp.Person
      <local-home>com.paynetech.cmp.PersonLocalHome</local-home>
      com.paynetech.cmp.PersonLocal

      <ejb-class>com.paynetech.cmp.PersonCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>MyLombozProject</abstract-schema-name>
      <cmp-field >
      <![CDATA[Returns the id]]>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the lastName]]>
      <field-name>lastName</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the firstName]]>
      <field-name>firstName</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the ssn]]>
      <field-name>ssn</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>


      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT OBJECT(a) FROM MyLombozProject as a]]></ejb-ql>


      <query-method>
      <method-name>findByLastName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT OBJECT(a) FROM MyLombozProject a where a.lastName = ?1]]></ejb-ql>

      <!-- Write a file named ejb-finders-PersonBean.xml if you want to define extra finders. -->


      <!--
      To add entity beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called entity-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Message Driven Beans -->
      <!--
      To add message driven beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called message-driven-beans.xml that contains
      the <message-driven></message-driven> markup for those beans.
      -->

      </enterprise-beans>

      <!-- Relationships -->

      <ejb-relation >
      <ejb-relation-name>Person-Company</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Person-belongs-to-Company</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>Person</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>company</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Company-has-many-Persons</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Company</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>


      <!-- Assembly Descriptor -->
      <assembly-descriptor >
      <!--
      To add additional assembly descriptor info here, add a file to your
      XDoclet merge directory called assembly-descriptor.xml that contains
      the <assembly-descriptor></assembly-descriptor> markup.
      -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- transactions -->

      <!-- finder transactions -->
      </assembly-descriptor>

      </ejb-jar>

      =====================
      Here's the jbosscmp-jdbc.xml
      =====================
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

      <jbosscmp-jdbc>

      java:/DefaultDS
      <datasource-mapping>Hypersonic SQL</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>


      <enterprise-beans>

      <!--
      To add beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml
      that contains the markup for those beans.
      -->


      <ejb-name>Company</ejb-name>
      <table-name>company</table-name>

      <cmp-field>
      <field-name>id</field-name>
      <column-name>id</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>name</column-name>

      </cmp-field>




      <ejb-name>Person</ejb-name>
      <table-name>Person</table-name>

      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>LAST_NAME</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>FIRST_NAME</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>ssn</field-name>
      <column-name>SSN</column-name>

      </cmp-field>



      </enterprise-beans>


      <ejb-relation>
      <ejb-relation-name>Person-Company</ejb-relation-name>

      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-belongs-to-Company</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Company-has-many-Persons</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>COMPANY</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>


      </jbosscmp-jdbc>