HHH-15759 Entity with @CollectionTable and entity with relation to element collection table, cause generate wrong FK, if first entity key field lexicographically after collection element.
This commit is contained in:
parent
d95bb9c40e
commit
9341df0b8b
|
@ -80,7 +80,11 @@ public class Set extends Collection {
|
|||
|
||||
void createPrimaryKey() {
|
||||
if ( !isOneToMany() ) {
|
||||
PrimaryKey pk = new PrimaryKey( getCollectionTable() );
|
||||
final Table collectionTable = getCollectionTable();
|
||||
PrimaryKey pk = collectionTable.getPrimaryKey();
|
||||
if ( pk == null ) {
|
||||
pk = new PrimaryKey( getCollectionTable() );
|
||||
}
|
||||
pk.addColumns( getKey() );
|
||||
for ( Selectable selectable : getElement().getSelectables() ) {
|
||||
if ( selectable instanceof Column ) {
|
||||
|
@ -94,7 +98,7 @@ public class Set extends Collection {
|
|||
}
|
||||
}
|
||||
if ( pk.getColumnSpan() != getKey().getColumnSpan() ) {
|
||||
getCollectionTable().setPrimaryKey( pk );
|
||||
collectionTable.setPrimaryKey( pk );
|
||||
}
|
||||
// else {
|
||||
//for backward compatibility, allow a set with no not-null
|
||||
|
|
Loading…
Reference in New Issue