Skip to content

Commit

Permalink
HHH-17965 @ElementCollection with @CollectionTable throws o.h.Mapping…
Browse files Browse the repository at this point in the history
…Exception Foreign key must have same number of columns as the referenced primary key
  • Loading branch information
dreab8 authored and beikov committed Apr 23, 2024
1 parent f46f0c4 commit ceb4d06
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions hibernate-core/src/main/java/org/hibernate/mapping/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,27 @@ void createPrimaryKey() {
PrimaryKey pk = collectionTable.getPrimaryKey();
if ( pk == null ) {
pk = new PrimaryKey( getCollectionTable() );
}
pk.addColumns( getKey() );
for ( Selectable selectable : getElement().getSelectables() ) {
if ( selectable instanceof Column ) {
Column col = (Column) selectable;
if ( !col.isNullable() ) {
pk.addColumn( col );
}
else {
return;
pk.addColumns( getKey() );
for ( Selectable selectable : getElement().getSelectables() ) {
if ( selectable instanceof Column ) {
Column col = (Column) selectable;
if ( !col.isNullable() ) {
pk.addColumn( col );
}
else {
return;
}
}
}
if ( pk.getColumnSpan() != getKey().getColumnSpan() ) {
collectionTable.setPrimaryKey( pk );
}
// else {
//for backward compatibility, allow a set with no not-null
//element columns, using all columns in the row locator SQL
//TODO: create an implicit not null constraint on all cols?
// }
}
if ( pk.getColumnSpan() != getKey().getColumnSpan() ) {
collectionTable.setPrimaryKey( pk );
}
// else {
//for backward compatibility, allow a set with no not-null
//element columns, using all columns in the row locator SQL
//TODO: create an implicit not null constraint on all cols?
// }
}
// else {
//create an index on the key columns??
Expand Down

0 comments on commit ceb4d06

Please sign in to comment.