HHH-13236 Maintain the old behaviour for non-composite types for better backward compatibility

This commit is contained in:
Dmitry Panov 2019-03-04 15:21:27 +00:00 committed by gbadner
parent aa2451407e
commit 86be5321d8
1 changed files with 9 additions and 2 deletions

View File

@ -339,7 +339,7 @@ public abstract class AbstractCollectionPersister
boolean hasNotNullableColumns = false;
boolean oneToMany = collectionBinding.isOneToMany();
boolean[] columnInsertability = null;
if (!oneToMany) {
if ( !oneToMany ) {
columnInsertability = collectionBinding.getElement().getColumnInsertability();
}
int j = 0;
@ -359,7 +359,14 @@ public abstract class AbstractCollectionPersister
elementColumnReaders[j] = col.getReadExpr( dialect );
elementColumnReaderTemplates[j] = col.getTemplate( dialect, factory.getSqlFunctionRegistry() );
elementColumnIsGettable[j] = true;
elementColumnIsSettable[j] = oneToMany || columnInsertability[j];
if ( elementType.isComponentType() ) {
// Implements desired behavior specifically for @ElementCollection mappings.
elementColumnIsSettable[j] = oneToMany || columnInsertability[j];
}
else {
// Preserves legacy non-@ElementCollection behavior
elementColumnIsSettable[j] = true;
}
elementColumnIsInPrimaryKey[j] = !col.isNullable();
if ( !col.isNullable() ) {
hasNotNullableColumns = true;