0 Replies Latest reply on Oct 2, 2003 2:31 PM by Prabhakar Krishnaswami

    Not able create a bean

    Prabhakar Krishnaswami Newbie

      I am new to CMR based entity beans and I am getting an error while trying to create a bean which has a relationship to another bean. This is in JBoss 320 environment. I am getting the following exception:

      INFO: set: GENDER='M'
      14:07:11,808 ERROR [AddressBean] Could not create entity
      org.firebirdsql.jdbc.FBSQLException: GDS Exception. validation error for column
      ADDRESSBEAN_UPK, value "*** null ***"
      at org.firebirdsql.jdbc.FBPreparedStatement.internalExecute(FBPreparedSt
      atement.java:458)
      at org.firebirdsql.jdbc.FBPreparedStatement.executeUpdate(FBPreparedStat
      ement.java:130)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdat
      e(WrappedPreparedStatement.java:308)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.executeInser
      t(JDBCAbstractCreateCommand.java:366)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInser
      t(JDBCAbstractCreateCommand.java:327)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBC
      AbstractCreateCommand.java:143)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStor
      eManager.java:575)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersisten
      ceManager.java:208)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.crea
      teEntity(CachedConnectionInterceptor.java:269)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:58
      0)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

      Here is the content of my jbosscmp-jdbc.xml:


      java:/july2003
      <datasource-mapping>Firebird</datasource-mapping>
      <create-table>true</create-table>
      <remove-table>true</remove-table>
      <pk-constraint>true</pk-constraint>
      <relation-mapping-style>foreign-key</relation-mapping-style>
      <read-ahead>
      on-load
      <page-size>500</page-size>
      <eager-load-group>group name</eager-load-group>
      </read-ahead>




      <ejb-name>AddressBean</ejb-name>
      <table-name>AddressBean</table-name>
      <cmp-field>
      <field-name>postalcode</field-name>
      <column-name>CODE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street2</field-name>
      <column-name>STREET2</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street1</field-name>
      <column-name>STREET1</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>region</field-name>
      <column-name>REGION</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>CITY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>country</field-name>
      <column-name>COUNTRY</column-name>
      </cmp-field>





      <ejb-name>PersonBean</ejb-name>
      <table-name>PersonBean</table-name>
      <cmp-field>
      <field-name>birthdate</field-name>
      <column-name>BIRTHDATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>gender</field-name>
      <column-name>GENDER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastname</field-name>
      <column-name>LASTNAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>middlename</field-name>
      <column-name>MIDDLENAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstname</field-name>
      <column-name>FIRSTNAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </cmp-field>









      <ejb-relation>
      <ejb-relation-name>Person-HomeAddress</ejb-relation-name>
      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-homeAddress</ejb-relationship-role-name>
      <key-fields>
      <key-field>

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

      </key-field>
      </key-fields>

      </ejb-relationship-role>



      <ejb-relationship-role>
      <ejb-relationship-role-name>homeAddress-belongs-to-Person</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-WorkAddress</ejb-relation-name>
      <foreign-key-mapping />
      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-WorkAddress</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>workAddress</column-name>

      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>WorkAddress-belongs-to-Person</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>


      Could somebody shed light on why I am getting this error? I will sure appreciate it.