0 Replies Latest reply on Apr 30, 2002 4:26 AM by giles

    ejbCreate with a composite key returning a null pointer

    giles

      Hi chaps

      I've seen this question posted a number of times, and have tryed all of the suggested solutions - however to no avail. I am assuming that my problem is slightly different. Any help would be great:

      I have a CMP bean that has a composite Primary key (PositionKey: made up of orgId and contactId, both ints). My ejbCreate method signature returns the key - my Composite key. I realise jboss expects YOU to return a null from the ejbCreate, and then handles the actuall key return itself.

      I think the problem occurs when jboss tryes to populate the composite key. On testing the ejbCreate, i get a :

      PositionEJB] error :170 - TRANSACTION ROLLBACK EXCEPTION:
      javax.transaction.TransactionRolledbackException: null
      Embedded Exception
      null; nested exception is:
      javax.ejb.EJBException: null
      Embedded Exception
      null
      javax.ejb.EJBException: null
      Embedded Exception
      null
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:870)
      at .............

      My ejb-jar looks like:


      no description
      <display-name>PositionEJB</display-name>
      <ejb-name>PositionEJB</ejb-name>
      au.com.eclipsegroup.worknet.PositionHome
      au.com.eclipsegroup.worknet.Position
      <ejb-class>au.com.eclipsegroup.worknet.PositionEJB</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>au.com.eclipsegroup.worknet.PositionKey</prim-key-class>
      False
      <cmp-field><field-name>contactId</field-name></cmp-field>
      <cmp-field><field-name>orgId</field-name></cmp-field>
      <cmp-field><field-name>title</field-name></cmp-field>
      <cmp-field><field-name>isPrimary</field-name></cmp-field>
      <cmp-field><field-name>isActive</field-name></cmp-field>
      <primkey-field></primkey-field>
      <resource-ref>
      <res-ref-name>jdbc/worknet</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      and my jaws looks like :


      <ejb-name>PositionEJB</ejb-name>
      <table-name>POSITION</table-name>
      <pk-constraint>true</pk-constraint>
      <cmp-field>
      <field-name>contactId</field-name>
      <column-name>CONTACT_ID</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>NUMBER(10)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>orgId</field-name>
      <column-name>ORG_ID</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>NUMBER(10)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>title</field-name>
      <column-name>TITLE</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR2(255)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>isPrimary</field-name>
      <column-name>IS_PRIMARY</column-name>
      <jdbc-type>BIT</jdbc-type>
      <sql-type>NUMBER(1)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>isActive</field-name>
      <column-name>IS_ACTIVE</column-name>
      <jdbc-type>BIT</jdbc-type>
      <sql-type>NUMBER(1)</sql-type>
      </cmp-field>

      When debugging this problem, it appears the null p is being through from within the createEntity in JAWS persistence layer.

      While debugging, I don't really get a chance to see what the values of this Composite key are before the exception is thrown. :(

      Could anyone shed some light on this situation? It's got me really buggered.

      Thanks in advance