private int doCascadeDelete(Identity oid, Object obj)
    {
        ClassDescriptor mif = _pb.getClassDescriptor(ProxyHelper.getRealClass(obj));
        Collection refDescs = mif.getObjectReferenceDescriptors();
        Collection colDescs = mif.getCollectionDescriptors();
        int countCascadeDeleted = 0;

        for (Iterator it = refDescs.iterator(); it.hasNext(); )
        {
            ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) it.next();

            if (rds.getOtmDependent())
            {
                PersistentField f = rds.getPersistentField();
                Object relObj = f.get(obj);

                if (relObj != null)
                {
                    countCascadeDeleted +=
                            markDelete(new Identity(relObj, _pb), oid, false);
                }
            }
        }

        for (Iterator it = colDescs.iterator(); it.hasNext(); )
        {
            CollectionDescriptor cds = (CollectionDescriptor) it.next();

            if (cds.getOtmDependent())
            {
                PersistentField f = cds.getPersistentField();
                Class type = f.getType();
                Object col = f.get(obj);

                if (col != null)
                {
                    Iterator colIterator;

                    if (Collection.class.isAssignableFrom(type))
                    {
                        colIterator = ((Collection) col).iterator();
                    }
                    else if (type.isArray())
                    {
                        colIterator = new ArrayIterator(col);
                    }
                    else
                    {
                        continue;
                    }

                    while (colIterator.hasNext())
                    {

                        countCascadeDeleted +=
                                markDelete(new Identity(colIterator.next(), _pb), oid, true);
                    }
                }
            }
        }

        return countCascadeDeleted;
    }
private int doCascadeDelete ( Identity oid , Object obj ) { ClassDescriptor mif = _pb . getClassDescriptor ( ProxyHelper . getRealClass ( obj ) ) ; Collection refDescs = mif . getObjectReferenceDescriptors ( ) ; Collection colDescs = mif . getCollectionDescriptors ( ) ; int countCascadeDeleted = 0 ; for ( Iterator it = refDescs . iterator ( ) ; it . hasNext ( ) ; ) { ObjectReferenceDescriptor rds = ( ObjectReferenceDescriptor ) it . next ( ) ; if ( rds . getOtmDependent ( ) ) { PersistentField f = rds . getPersistentField ( ) ; Object relObj = f . get ( obj ) ; if ( relObj != null ) { countCascadeDeleted += markDelete ( new Identity ( relObj , _pb ) , oid , false ) ; } } } for ( Iterator it = colDescs . iterator ( ) ; it . hasNext ( ) ; ) { CollectionDescriptor cds = ( CollectionDescriptor ) it . next ( ) ; if ( cds . getOtmDependent ( ) ) { PersistentField f = cds . getPersistentField ( ) ; Class type = f . getType ( ) ; Object col = f . get ( obj ) ; if ( col != null ) { Iterator colIterator ; if ( Collection . class . isAssignableFrom ( type ) ) { colIterator = ( ( Collection ) col ) . iterator ( ) ; } else if ( type . isArray ( ) ) { colIterator = new ArrayIterator ( col ) ; } else { continue ; } while ( colIterator . hasNext ( ) ) { countCascadeDeleted += markDelete ( new Identity ( colIterator . next ( ) , _pb ) , oid , true ) ; } } } } return countCascadeDeleted ; }
Mark for deletion all dependent objects (via references and collections).
@return the number of deleted objects