User: dsundstrom Date: 01/11/13 12:15:24 Modified: src/main/org/jboss/ejb/plugins/cmp/jdbc JDBCRemoveEntityCommand.java Log: Fixed a bug where if a related entity was related two ways with cascade delete, the command would attempt to remove the entity twice. Now before an entity is deleted, the command checks to see if the entity is a memeber of the already deleted set. Revision Changes Path 1.7 +10 -3 jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java Index: JDBCRemoveEntityCommand.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JDBCRemoveEntityCommand.java 2001/11/10 22:50:25 1.6 +++ JDBCRemoveEntityCommand.java 2001/11/13 20:15:24 1.7 @@ -27,7 +27,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Joe Shevland</a> * @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class JDBCRemoveEntityCommand extends JDBCUpdateCommand @@ -78,6 +78,7 @@ throw new RemoveException("Could not remove " + context.getId()); } + HashSet deletedEntities = new HashSet(); for(int i=0; i<cmrFields.length; i++) { if(cmrFields[i].getMetaData().getRelatedRole().isCascadeDelete()) { Object oldRelation = oldRelationMap.get(cmrFields[i]); @@ -85,12 +86,18 @@ Iterator oldValues = ((Collection)oldRelation).iterator(); while(oldValues.hasNext()) { EJBLocalObject oldValue = (EJBLocalObject)oldValues.next(); - oldValue.remove(); + if(!deletedEntities.contains(oldValue)) { + deletedEntities.add(oldValue); + oldValue.remove(); + } } } else { EJBLocalObject oldValue = (EJBLocalObject)oldRelation; if(oldValue != null) { - oldValue.remove(); + if(!deletedEntities.contains(oldValue)) { + deletedEntities.add(oldValue); + oldValue.remove(); + } } } }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development