1 Reply Latest reply on Jan 4, 2003 3:22 PM by Prasanna Tuladhar

    relation table maping notworks

    wangzx Newbie

      In our projects, we found that the many-many mapping using relation table mapping not worked at all.

      we can deploy the jar to jboss server, and we can call add method on the collection returned by a getCMR methods, but no INSERT statement executed at all to insert a record into the relation table.

      i looked at the source code at org.jboss.ejb.EntityContainer.storeEntity() method:
      public void storeEntity(EntityEnterpriseContext ctx) throws Exception
      {
      if (ctx.getId() != null)
      {
      if(getPersistenceManager().isModified(ctx)) {
      getPersistenceManager().storeEntity(ctx);
      }
      }
      }
      which looks that only if a ctx is modified, will the relation stored also, but org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.isDirty() method looks like:

      public boolean isDirty(EntityEnterpriseContext ctx) {
      if(!hasForeignKey()) {
      return false;
      }

      for(Iterator fields = foreignKeyFields.iterator(); fields.hasNext();) {
      JDBCCMPFieldBridge field = (JDBCCMPFieldBridge)fields.next();
      if(field.isDirty(ctx)) {
      return true;
      }
      }
      return false;
      }

      it looks that it doesn;t work for a relation table mapping.

      Is there a bug? or is it just my fault of using the many-many relationship in jboss?

      Hope somebody can help us! we need this feature in our project. Very thanks.