}
}
private void cascadeDeleteCollectionReferences(ObjectEnvelope source, List descriptor, List alreadyPrepared)
{
PersistenceBroker pb = getTransaction().getBroker();
for(int i = 0; i < descriptor.size(); i++)
{
CollectionDescriptor col = (CollectionDescriptor) descriptor.get(i);
boolean cascadeDelete = getTransaction().cascadeDeleteFor(col);
Object collOrArray = col.getPersistentField().get(source.getObject());
// TODO: remove cast
CollectionProxyDefaultImpl proxy = (CollectionProxyDefaultImpl) ProxyHelper.getCollectionProxy(collOrArray);
// on delete we have to materialize dependent objects
if(proxy != null)
{
collOrArray = proxy.getData();
}
if(collOrArray != null)
{
Iterator it = BrokerHelper.getCollectionIterator(collOrArray);
while(it.hasNext())
{
Object colObj = ProxyHelper.getRealObject(it.next());
Identity oid = pb.serviceIdentity().buildIdentity(colObj);
ObjectEnvelope colMod = get(oid, colObj, false);
if(cascadeDelete)
{
colMod.setModificationState(colMod.getModificationState().markDelete());
cascadeDeleteFor(colMod, alreadyPrepared);