3 Replies Latest reply on Mar 8, 2002 11:46 AM by zerosleep

    cmr-fields that return collections shouldn't return null? ri

    zerosleep Newbie

      I have a cmr field called phoneNumbers that is supposed to return an empty collection if there are 0 Local objects from the EJB I have a relationship with.

      The deployment goes fine and I've ensured that I have all the descriptor files setup correctly, but JBoss generates the following errors:

      java.lang.NullPointerException
      at org.jboss.ejb.plugins.cmp.jdbc.SQLUtil.getColumnNamesClause(SQLUtil.java:79)
      at org.jboss.ejb.plugins.cmp.jdbc.SQLUtil.getColumnNamesClause(SQLUtil.java:71)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.execute(JDBCLoadRelationCommand.java:51)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadRelation(JDBCStoreManager.java:471)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:794)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getValue(JDBCCMRFieldBridge.java:456)
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:111)
      at org.jboss.proxy.compiler.ProxyCompiler$Runtime.invoke(ProxyCompiler.java:89)

      Code snippet:

      public void addPhoneNumber(...) {
      ...
      Collection phoneNumbers = this.getPhoneNumbers(); // exception thrown here
      ....
      }

      The code is something I've copied from O'Reillys EJB 3rd Edition book, chapter 7, page 196 - 204. I'm running the latest snapshot of JBoss 3. In the book, it says:

      "If no beans have been added to the phoneNumbers relationship field, the getPhoneNumbers() method will return an empty Collection object. relationship fields never return null. The collection object used with the relationship field is implemented by the container system, propietary to the vendor, and tightly coupled with the inner workings of the container."

      Am I missing something here?