1 Reply Latest reply on Aug 5, 2003 3:32 AM by Joachim Van der Auwera

    CMR field cleared for no reason

    Joachim Van der Auwera Expert

      I have two beans, with a uni-directional 1-N CMR link between them.

      When creating several instances, all linking to the same other bean, only the last entity gets the link filled in. All the others have their link reset to zero.

      See log excerpt (somewhat shortened), the first line indicates the setting of the CMR field :

      ------------ start of log excerpt
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.DMBatchEJB] No preload data found: entity=DMBatchEJB pk=58ktIiP8noJdDR
      2003-08-04 17:48:34,578 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.DMBatchEJB] Executing SQL: SELECT UNID_UOID FROM WEIGHT WHERE (f_Batch_UOID=?)
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.UOID] Set parameter: index=1, jdbcType=CHAR, value=58ktIiP8noJdDR
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.UOID] Get result: index=1, javaType=java.lang.String, Simple, value=98ktIiP8noJdDR
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.DMWeightEJB] Add preload data: entity=DMWeightEJB pk=98ktIiP8noJdDR field=batch
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.DMWeightEJB] RESET PERSISTENCE CONTEXT: id=98ktIiP8noJdDR
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.DMWeightEJB] load data: entity=DMWeightEJB pk=98ktIiP8noJdDR
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.DMWeightEJB] Preloading data: entity=DMWeightEJB pk=98ktIiP8noJdDR cmrField=batch
      2003-08-04 17:48:34,578 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.DMWeightEJB] Default eager-load for entity: readahead=null
      2003-08-04 17:48:34,578 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.DMWeightEJB] Executing SQL: SELECT UNID_CREATION, UNID_MODIFIED, UNID_TYPE, f_Classification, f_Classificator, f_ClientComment, f_Readability, f_RefusedMeasurement, f_IncompleteCarcas, f_Presentation, f_Article, f_ArticleDestination, f_ArticleVariant, f_Count, f_ConsumeBefore, f_UnitWeight, f_UnitTare, f_PackagingNumber, f_PackagingPiece, f_PackagingType, f_PackagingTotal, f_Processed, f_Stock, f_StockLocation, f_Reprint, f_CloneUnlock, f_Imprint, f_Reference, f_LocalReference, f_Locked, f_WeightNet, f_WeightGross, f_WeightTare, f_WeightManual, f_WeightCalculated, f_WeightTime, f_Cancelled, f_SequenceNumber, f_MachineClassification, f_HamThickness, f_HamAngle, f_Gender, f_MeatPercentage, f_MeatThickness, f_BaconThickness, f_Reflection, f_Damage, f_PistolOperator, f_MachineComment, f_MachineWeightComment, f_MachinePistolComment, f_MachineCameraComment, f_CameraPictureType, f_CameraPicture, f_StockCompany_UOID, f_PackagingPallet_UOID, f_ReplacedBy_UOID, f_StockArrival_UOID, f_PackagingBox_UOID FROM WEIGHT WHERE (UNID_UOID=?)
      2003-08-04 17:48:34,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.UOID] Set parameter: index=1, jdbcType=CHAR, value=98ktIiP8noJdDR
      2003-08-04 17:48:34,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.DMWeightEJB] Remove relation: field=batch id=98ktIiP8noJdDR relatedId=58ktIiP8noJdDR
      2003-08-04 17:48:34,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.DMBatchEJB] Remove relation: field=DMWeightEJB_batch id=58ktIiP8noJdDR relatedId=98ktIiP8noJdDR
      2003-08-04 17:48:34,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.DMBatchEJB] Add relation: field=DMWeightEJB_batch id=58ktIiP8noJdDR relatedId=A8ktIiP8noJdDR
      2003-08-04 17:48:34,593 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.DMWeightEJB] Executing SQL: UPDATE WEIGHT SET UNID_MODIFIED=?, f_Locked=?, f_WeightNet=?, f_WeightGross=?, f_WeightTare=?, f_WeightCalculated=?, f_WeightTime=?, f_Batch_UOID=? WHERE UNID_UOID=?
      2003-08-04 17:48:34,609 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.unidModificationDate] Set parameter: index=1, jdbcType=TIMESTAMP, value=2003-08-04 17:48:34.593
      2003-08-04 17:48:34,609 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.UOID] Set parameter: index=8, jdbcType=CHAR, value=58ktIiP8noJdDR
      2003-08-04 17:48:34,609 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.UOID] Set parameter: index=9, jdbcType=CHAR, value=A8ktIiP8noJdDR
      2003-08-04 17:48:34,609 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.DMWeightEJB] Rows affected = 1
      2003-08-04 17:48:34,609 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.DMBatchEJB] Store command NOT executed. Entity is not dirty: pk=58ktIiP8noJdDR
      2003-08-04 17:48:34,609 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.DMWeightEJB] Executing SQL: UPDATE WEIGHT SET f_Batch_UOID=? WHERE UNID_UOID=?
      2003-08-04 17:48:34,609 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.DMWeightEJB.UOID] Set parameter: index=1, jdbcType=CHAR, value=NULL
      ------------ end of log excerpt


      ------------ definition in ejb-jar.xml
      <ejb-relation >
      <ejb-relation-name>Weight-Batch</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Weight-Batch-table</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>DMWeightEJB</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>batch</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>Weight-Batch-field</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>DMBatchEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>
      ------------ end definition in ejb-jar.xml


      ------------ definition in jbosscmp-jdbc.xml
      <ejb-relation>
      <ejb-relation-name>Weight-Batch</ejb-relation-name>

      <foreign-key-mapping/>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Weight-Batch-table</ejb-relationship-role-name>
      <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Weight-Batch-field</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>UOID</field-name>
      <column-name>f_Batch</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      ------------ end definition in jbosscmp-jdbc.xml

      Hope this makes sense...

      Thanks for the help,
      Joachim