/** * 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); } } } } }
public void setInversePropertyName(String inversePropertyName) { setReferencedPropertyName(inversePropertyName); this.inversePropertyName = inversePropertyName; } }
PropertyMapping<Property> associationPropertyMapping = manyToMany.getMapping(); PersistentEntity associatedEntity = manyToMany.getAssociatedEntity(); if(associatedEntity != null) { persistentEntity, nativeKey, manyToMany.getName()); if (cached == null) { Collection collection; Collection keys = getManyToManyKeys(persistentEntity, obj, nativeKey, nativeEntry, manyToMany); if (List.class.isAssignableFrom(manyToMany.getType())) { collection = new PersistentList(keys, childType, session); ea.setPropertyNoConversion(manyToMany.getName(), collection); else if (Set.class.isAssignableFrom(manyToMany.getType())) { collection = new PersistentSet(keys, childType, session); ea.setPropertyNoConversion(manyToMany.getName(), collection); AssociationIndexer indexer = getAssociationIndexer(nativeEntry, manyToMany); if (indexer == null) { if (List.class.isAssignableFrom(manyToMany.getType())) { collection = Collections.emptyList(); else if (Set.class.isAssignableFrom(manyToMany.getType())) { collection = Collections.emptySet(); List keys = indexer.query(nativeKey); collection = session.retrieveAll(childType, keys);
((ManyToMany)association).setInversePropertyName(relatedClassPropertyName); many = true;
final ManyToMany manyToMany = (ManyToMany) prop; final Object propValue = entityAccess.getProperty(manyToMany.getName()); if (propValue instanceof Collection) { Collection associatedObjects = (Collection) propValue;
return addUnderscore(left, propertyColumnName); return addUnderscore(right, namingStrategy.propertyToColumnName(((ManyToMany) property).getInversePropertyName()));
ManyToMany manyToMany = getAnnotation(readMethod, field, ManyToMany.class); if (!manyToMany.mappedBy().equals("")) { ((org.grails.datastore.mapping.model.types.ManyToMany)association).setInversePropertyName(manyToMany.mappedBy()); referencedPropertyName = manyToMany.mappedBy(); } else {
final ManyToMany manyToMany = (ManyToMany) persistentProperty; final Object propValue = embeddedEntityAccess.getProperty(manyToMany.getName()); if (propValue instanceof Collection) { Collection associatedObjects = (Collection) propValue;