HHH-17468 Allow mapping read-only basic collections

This commit is contained in:
Marco Belladelli 2023-11-27 11:35:16 +01:00 committed by Christian Beikov
parent cceb00518e
commit f50cb5530b
2 changed files with 6 additions and 10 deletions

View File

@ -195,6 +195,7 @@ public abstract class AbstractCollectionPersister
private final boolean isLazy;
private final boolean isExtraLazy;
protected final boolean isInverse;
private final boolean keyIsUpdateable;
private final boolean isMutable;
private final boolean isVersioned;
protected final int batchSize;
@ -492,6 +493,8 @@ public abstract class AbstractCollectionPersister
isInverse = collectionBootDescriptor.isInverse();
keyIsUpdateable = collectionBootDescriptor.getKey().isUpdateable();
if ( collectionBootDescriptor.isArray() ) {
elementClass = ( (org.hibernate.mapping.Array) collectionBootDescriptor ).getElementClass();
}
@ -1098,7 +1101,7 @@ public abstract class AbstractCollectionPersister
}
protected boolean isRowDeleteEnabled() {
return true;
return keyIsUpdateable;
}
@Override
@ -1107,7 +1110,7 @@ public abstract class AbstractCollectionPersister
}
protected boolean isRowInsertEnabled() {
return true;
return keyIsUpdateable;
}
public String getOwnerEntityName() {

View File

@ -102,7 +102,6 @@ public class OneToManyPersister extends AbstractCollectionPersister {
private final boolean cascadeDeleteEnabled;
private final boolean keyIsNullable;
private final boolean keyIsUpdateable;
private final MutationExecutorService mutationExecutorService;
@Deprecated(since = "6.0")
@ -121,7 +120,6 @@ public class OneToManyPersister extends AbstractCollectionPersister {
cascadeDeleteEnabled = collectionBinding.getKey().isCascadeDeleteEnabled()
&& creationContext.getDialect().supportsCascadeDelete();
keyIsNullable = collectionBinding.getKey().isNullable();
keyIsUpdateable = collectionBinding.getKey().isUpdateable();
this.rowMutationOperations = buildRowMutationOperations();
@ -156,12 +154,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
@Override
protected boolean isRowDeleteEnabled() {
return keyIsUpdateable && keyIsNullable;
}
@Override
protected boolean isRowInsertEnabled() {
return keyIsUpdateable;
return super.isRowDeleteEnabled() && keyIsNullable;
}
public boolean isCascadeDeleteEnabled() {