@Override public boolean isDeleteCascaded(ManagedType<?> ownerType, String elementCollectionPath, String attributeName) { Type elementType = getCollectionPersister(ownerType, elementCollectionPath).getElementType(); if (!(elementType instanceof ComponentType)) { // This can only happen for collection/join table target attributes, where it is irrelevant return false; } ComponentType componentType = (ComponentType) elementType; String subAttribute = attributeName.substring(elementCollectionPath.length() + 1); // Component types only store direct properties, so we have to go deeper String[] propertyParts = subAttribute.split("\\."); int propertyIndex = 0; for (; propertyIndex < propertyParts.length - 1; propertyIndex++) { int index = componentType.getPropertyIndex(propertyParts[propertyIndex]); Type propertyType = componentType.getSubtypes()[index]; if (propertyType instanceof ComponentType) { componentType = (ComponentType) propertyType; } else { // The association property is just as good as the id property of the association for our purposes // So we stop here and query the association property instead break; } } try { return (boolean) DO_CASCADE_METHOD.invoke(componentType.getCascadeStyle(propertyIndex), DELETE_CASCADE); } catch (Exception ex) { throw new RuntimeException("Could not access orphan removal information. Please report your version of hibernate so we can provide support for it!", ex); } }
@Override public boolean isOrphanRemoval(ManagedType<?> ownerType, String elementCollectionPath, String attributeName) { Type elementType = getCollectionPersister(ownerType, elementCollectionPath).getElementType(); if (!(elementType instanceof ComponentType)) { // This can only happen for collection/join table target attributes, where it is irrelevant return false; } ComponentType componentType = (ComponentType) elementType; String subAttribute = attributeName.substring(elementCollectionPath.length() + 1); // Component types only store direct properties, so we have to go deeper String[] propertyParts = subAttribute.split("\\."); int propertyIndex = 0; for (; propertyIndex < propertyParts.length - 1; propertyIndex++) { int index = componentType.getPropertyIndex(propertyParts[propertyIndex]); Type propertyType = componentType.getSubtypes()[index]; if (propertyType instanceof ComponentType) { componentType = (ComponentType) propertyType; } else { // The association property is just as good as the id property of the association for our purposes // So we stop here and query the association property instead break; } } try { return (boolean) HAS_ORPHAN_DELETE_METHOD.invoke(componentType.getCascadeStyle(propertyIndex)); } catch (Exception ex) { throw new RuntimeException("Could not access orphan removal information. Please report your version of hibernate so we can provide support for it!", ex); } }
@Override public boolean isOrphanRemoval(ManagedType<?> ownerType, String elementCollectionPath, String attributeName) { Type elementType = getCollectionPersister(ownerType, elementCollectionPath).getElementType(); if (!(elementType instanceof ComponentType)) { // This can only happen for collection/join table target attributes, where it is irrelevant return false; } ComponentType componentType = (ComponentType) elementType; String subAttribute = attributeName.substring(elementCollectionPath.length() + 1); // Component types only store direct properties, so we have to go deeper String[] propertyParts = subAttribute.split("\\."); int propertyIndex = 0; for (; propertyIndex < propertyParts.length - 1; propertyIndex++) { int index = componentType.getPropertyIndex(propertyParts[propertyIndex]); Type propertyType = componentType.getSubtypes()[index]; if (propertyType instanceof ComponentType) { componentType = (ComponentType) propertyType; } else { // The association property is just as good as the id property of the association for our purposes // So we stop here and query the association property instead break; } } return componentType.getCascadeStyle(propertyIndex).hasOrphanDelete(); }
@Override public boolean isDeleteCascaded(ManagedType<?> ownerType, String elementCollectionPath, String attributeName) { Type elementType = getCollectionPersister(ownerType, elementCollectionPath).getElementType(); if (!(elementType instanceof ComponentType)) { // This can only happen for collection/join table target attributes, where it is irrelevant return false; } ComponentType componentType = (ComponentType) elementType; String subAttribute = attributeName.substring(elementCollectionPath.length() + 1); // Component types only store direct properties, so we have to go deeper String[] propertyParts = subAttribute.split("\\."); int propertyIndex = 0; for (; propertyIndex < propertyParts.length - 1; propertyIndex++) { int index = componentType.getPropertyIndex(propertyParts[propertyIndex]); Type propertyType = componentType.getSubtypes()[index]; if (propertyType instanceof ComponentType) { componentType = (ComponentType) propertyType; } else { // The association property is just as good as the id property of the association for our purposes // So we stop here and query the association property instead break; } } return componentType.getCascadeStyle(propertyIndex).doCascade(CascadingAction.DELETE); }