Skip to content

Commit 316c7af

Browse files
dreab8beikov
authored andcommitted
HHH-17420 JoinColumn throws an AnnotationException
1 parent aef88b1 commit 316c7af

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,16 @@ else if ( columnOwner instanceof Join ) {
452452
// which are mapped to that column. (There might be multiple such
453453
// properties for each column.)
454454
if ( columnOwner instanceof PersistentClass ) {
455-
PersistentClass persistentClass = (PersistentClass) columnOwner;
455+
final PersistentClass persistentClass = (PersistentClass) columnOwner;
456+
// Process ToOne associations after Components, Basic and Id properties
457+
final List<Property> toOneProperties = new ArrayList<>();
456458
for ( Property property : persistentClass.getReferenceableProperties() ) {
457-
matchColumnsByProperty( property, columnsToProperty );
459+
if ( property.getValue() instanceof ToOne ) {
460+
toOneProperties.add( property );
461+
}
462+
else {
463+
matchColumnsByProperty( property, columnsToProperty );
464+
}
458465
}
459466
if ( persistentClass.hasIdentifierProperty() ) {
460467
matchColumnsByProperty( persistentClass.getIdentifierProperty(), columnsToProperty );
@@ -466,6 +473,9 @@ else if ( columnOwner instanceof Join ) {
466473
matchColumnsByProperty( p, columnsToProperty );
467474
}
468475
}
476+
for ( Property property : toOneProperties ) {
477+
matchColumnsByProperty( property, columnsToProperty );
478+
}
469479
}
470480
else {
471481
for ( Property property : ((Join) columnOwner).getProperties() ) {

0 commit comments

Comments
 (0)