0 Replies Latest reply on Nov 1, 2004 1:05 PM by neil blue

    CMR and unknown-pk dont work together

    neil blue Newbie

      Hello,

      Using 3.2.5:

      I haven an ejb with a 1:M CMR. Both ends of the relationship are of the same type.

      I have abstract accessor methods:

      public abstract RdfStatementLocal getParent();
      public abstract void setParent(RdfStatementLocal parent);

      where RdfStatementLocal is the local bean interface. The primary key for the bean is an unknown-pk to allow for auto-increment primary keys.

      ...
       <cmp-field>
       <field-name>parent</field-name>
      
       <jdbc-type>INTEGER</jdbc-type>
       <sql-type>INT(11)</sql-type>
      
       </cmp-field>
      
       <unknown-pk>
       <unknown-pk-class>java.lang.Integer</unknown-pk-class>
       <field-name>id</field-name>
       <column-name>id</column-name>
       <jdbc-type>INTEGER</jdbc-type>
       <sql-type>INT(11)</sql-type>
       <auto-increment/>
       </unknown-pk>
       <entity-command name="mysql-get-generated-keys">
       </entity-command>
      


       <relationships>
       <ejb-relation>
       <ejb-relation-name>derived-from</ejb-relation-name>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>child</ejb-relationship-role-name>
       <fk-constraint>true</fk-constraint>
       <key-fields/>
      
       </ejb-relationship-role>
       <ejb-relationship-role>
       <ejb-relationship-role-name>parent</ejb-relationship-role-name>
       <key-fields>
       <key-field>
       <field-name>id</field-name>
       <column-name>id</column-name>
       <jdbc-type>INTEGER</jdbc-type>
       <sql-type>INT(11)</sql-type>
       </key-field>
       </key-fields>
      
       </ejb-relationship-role>
       </ejb-relation>
       </relationships>
      


      When I try to set one of these fields I get the following error, which looks like jboss is not using the primary key for storeage.

      org.jboss.tm.JBossTransactionRolledbackLocalException: null; CausedByException is:
      Unable to commit, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=wd-ukblueneil//25, BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Internal error setting parameters for field parent; CausedByException is:
      Cannot convert class $Proxy45 to SQL type requested due to java.lang.ClassCastException - null); - nested throwable: (org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=wd-ukblueneil//25, BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Internal error setting parameters for field parent; CausedByException is:
      Cannot convert class $Proxy45 to SQL type requested due to java.lang.ClassCastException - null))
      at org.jboss.ejb.plugins.TxInterceptorCMT.throwJBossException(TxInterceptorCMT.java:546)
      at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:461)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:324)
      
      


      any help please
      Neil