0 Replies Latest reply on Sep 9, 2003 7:02 AM by Joachim Van der Auwera

    CMR with 1-N with relation-table problem

    Joachim Van der Auwera Expert

      I have a CMR relation defined as follows (using xdoclet)

      /**
      * @ejb.interface-method
      * @ejb.relation
      * name="WeightGroup-Weight"
      * role-name="WeightGroup-Weight-table"
      * target-ejb="DMWeightEJB"
      * target-role-name="WeightGroup-Weight-field"
      *
      * @jboss.relation
      * related-pk-field="UOID"
      * fk-column="f_Weight"
      * @jboss.target-relation
      * related-pk-field="UOID"
      * fk-column="WeightGroup"
      * @jboss.relation-mapping style="relation-table"
      * @jboss.relation-table
      * table-name="WeightGroup_Weight"
      */
      public abstract Collection getWeight();

      However, I get a NPE when I try to call getWeight on an object which has one
      (or more) objects in the relationship.

      2003-09-04 19:43:52,953 ERROR [org.jboss.ejb.plugins.LogInterceptor]
      TransactionRolledbackLocalException in method: public abstract
      java.util.Collection org.ictrace.client.DMWeightGroupEJBLocal.getWeight(),
      causedBy:
      java.lang.NullPointerException
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.execute(JDBCLoadRelat
      ionCommand.java:141)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadRelation(JDBCStoreManage
      r.java:705)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBr
      idge.java:1119)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getInstanceValue(JD
      BCCMRFieldBridge.java:559)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getValue(JDBCCMRFie
      ldBridge.java:515)
      at
      org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(Entity
      BridgeInvocationHandler.java:124)
      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      at org.ictrace.server.DMWeightGroupEJBCMP$Proxy.getWeight()
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
      )
      at
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
      .java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at
      org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.ja
      va:1059)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationIn
      terceptor.java:95)
      at
      org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchron
      izationInterceptor.java:301)
      at
      org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach
      edConnectionInterceptor.java:186)
      at
      org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInt
      erceptor.java:82)
      at
      org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterce
      ptor.java:174)
      at
      org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.jav
      a:89)
      at
      org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterce
      ptor.java:53)
      at
      org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor
      .java:84)
      at
      org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.
      java:243)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      at
      org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:11
      7)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at
      org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinde
      rInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at
      org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFacto
      ry.java:353)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy96.getWeight(Unknown Source)

      When I switch trace loggin on for the CMR stuff, I see that a query is
      started

      SELECT WeightGroup_UOID, f_Weight_UOID FROM WEIGHTGROUP_WEIGHT WHERE
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR (WeightGroup_UOID=?) OR
      (WeightGroup_UOID=?)

      with as parameters all the possible weightgroup_uoid values (from the
      weightgroup table, not from the relation table), which seems to be a query
      which will return way too many results. Once the first result is retrieved,
      the crash occurs.

      I am using mode A (no other DB modifying users).

      Can anybody help me solve this problem?

      Thanks,
      Joachim