HHH-17420 JoinColumn throws an AnnotationException

This commit is contained in:
Andrea Boriero 2024-01-22 14:47:41 +01:00 committed by Christian Beikov
parent 2ae10fafd2
commit f24669ca93
1 changed files with 12 additions and 2 deletions

View File

@ -452,9 +452,16 @@ public class BinderHelper {
// which are mapped to that column. (There might be multiple such
// properties for each column.)
if ( columnOwner instanceof PersistentClass ) {
PersistentClass persistentClass = (PersistentClass) columnOwner;
final PersistentClass persistentClass = (PersistentClass) columnOwner;
// Process ToOne associations after Components, Basic and Id properties
final List<Property> toOneProperties = new ArrayList<>();
for ( Property property : persistentClass.getReferenceableProperties() ) {
matchColumnsByProperty( property, columnsToProperty );
if ( property.getValue() instanceof ToOne ) {
toOneProperties.add( property );
}
else {
matchColumnsByProperty( property, columnsToProperty );
}
}
if ( persistentClass.hasIdentifierProperty() ) {
matchColumnsByProperty( persistentClass.getIdentifierProperty(), columnsToProperty );
@ -466,6 +473,9 @@ public class BinderHelper {
matchColumnsByProperty( p, columnsToProperty );
}
}
for ( Property property : toOneProperties ) {
matchColumnsByProperty( property, columnsToProperty );
}
}
else {
for ( Property property : ((Join) columnOwner).getProperties() ) {