/** * Delete collections before owner delete. */ protected void cascadeBeforeDelete(PersistentEntity persistentEntity, EntityAccess entityAccess, K key, Object instance) { List<PersistentProperty> props = persistentEntity.getPersistentProperties(); for (PersistentProperty prop : props) { String propertyKey = getPropertyKey(prop); if (prop instanceof OneToMany) { OneToMany oneToMany = (OneToMany)prop; if (oneToMany.isOwningSide() && oneToMany.doesCascade(CascadeType.REMOVE)) { if (Collection.class.isAssignableFrom(oneToMany.getType())) { cascadeDeleteCollection(entityAccess, oneToMany); } } } else if (prop instanceof ManyToMany) { ManyToMany manyToMany = (ManyToMany)prop; if (manyToMany.isOwningSide() && manyToMany.doesCascade(CascadeType.REMOVE)) { Object propValue = entityAccess.getProperty(manyToMany.getName()); if (Collection.class.isAssignableFrom(manyToMany.getType())) { cascadeDeleteCollection(entityAccess, manyToMany); } } } } }
persistentEntity, nativeKey, manyToMany.getName()); if (cached == null) { Collection collection; if (List.class.isAssignableFrom(manyToMany.getType())) { collection = new PersistentList(keys, childType, session); ea.setPropertyNoConversion(manyToMany.getName(), collection); ea.setPropertyNoConversion(manyToMany.getName(), collection); List keys = indexer.query(nativeKey); collection = session.retrieveAll(childType, keys); ea.setProperty(manyToMany.getName(), collection); persistentEntity, nativeKey, collection, manyToMany.getName()); ea.setProperty(manyToMany.getName(), cached);
final ManyToMany manyToMany = (ManyToMany) prop; final Object propValue = entityAccess.getProperty(manyToMany.getName()); if (propValue instanceof Collection) { Collection associatedObjects = (Collection) propValue;
final ManyToMany manyToMany = (ManyToMany) persistentProperty; final Object propValue = embeddedEntityAccess.getProperty(manyToMany.getName()); if (propValue instanceof Collection) { Collection associatedObjects = (Collection) propValue;