HHH-11038 : Invalid statement generated for @MapKeyColumn(updatable=false) for @OneToMany
(cherry picked from commit 87e69c9d34
)
This commit is contained in:
parent
37ffbfd3d5
commit
86cd386ce9
|
@ -84,7 +84,11 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
.addPrimaryKeyColumns( keyColumnNames );
|
||||
|
||||
if ( hasIndex && !indexContainsFormula ) {
|
||||
update.addColumns( indexColumnNames, "null" );
|
||||
for ( int i = 0 ; i < indexColumnNames.length ; i++ ) {
|
||||
if ( indexColumnIsSettable[i] ) {
|
||||
update.addColumn( indexColumnNames[i], "null" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasWhere ) {
|
||||
|
@ -108,7 +112,11 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
.addColumns( keyColumnNames );
|
||||
|
||||
if ( hasIndex && !indexContainsFormula ) {
|
||||
update.addColumns( indexColumnNames );
|
||||
for ( int i = 0 ; i < indexColumnNames.length ; i++ ) {
|
||||
if ( indexColumnIsSettable[i] ) {
|
||||
update.addColumn( indexColumnNames[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//identifier collections not supported for 1-to-many
|
||||
|
@ -132,7 +140,11 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
update.addPrimaryKeyColumns( new String[] {identifierColumnName} );
|
||||
}
|
||||
if ( hasIndex && !indexContainsFormula ) {
|
||||
update.addColumns( indexColumnNames );
|
||||
for ( int i = 0 ; i < indexColumnNames.length ; i++ ) {
|
||||
if ( indexColumnIsSettable[i] ) {
|
||||
update.addColumn( indexColumnNames[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return update.toStatementString();
|
||||
|
@ -149,7 +161,11 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
.addColumns( keyColumnNames, "null" );
|
||||
|
||||
if ( hasIndex && !indexContainsFormula ) {
|
||||
update.addColumns( indexColumnNames, "null" );
|
||||
for ( int i = 0 ; i < indexColumnNames.length ; i++ ) {
|
||||
if ( indexColumnIsSettable[i] ) {
|
||||
update.addColumn( indexColumnNames[i], "null" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) {
|
||||
|
@ -191,7 +207,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
boolean resetIndex,
|
||||
SessionImplementor session) {
|
||||
// If one-to-many and inverse, still need to create the index. See HHH-5732.
|
||||
if ( isInverse && hasIndex && !indexContainsFormula ) {
|
||||
if ( isInverse && hasIndex && !indexContainsFormula && ArrayHelper.countTrue( indexColumnIsSettable ) > 0 ) {
|
||||
try {
|
||||
if ( entries.hasNext() ) {
|
||||
int nextIndex = resetIndex ? 0 : getSize( id, session );
|
||||
|
|
Loading…
Reference in New Issue