HHH-14467 Fix relative ordering of second pass for associations and derived IDs
Always execute second pass for associations referencing an entity with derived ID after the second pass for that entity's derived ID. Signed-off-by: Yoann Rodière <yoann@hibernate.org>
This commit is contained in:
parent
496e5995b2
commit
9b991310b5
|
@ -66,19 +66,32 @@ public class ToOneFkSecondPass extends FkSecondPass {
|
|||
//try explicit identifier property
|
||||
return path.startsWith( property.getName() + "." );
|
||||
}
|
||||
else {
|
||||
//try the embedded property
|
||||
//embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
|
||||
if ( path.startsWith( "id." ) ) {
|
||||
else if ( path.startsWith( "id." ) ) {
|
||||
KeyValue valueIdentifier = persistentClass.getIdentifier();
|
||||
String localPath = path.substring( 3 );
|
||||
if ( valueIdentifier instanceof Component ) {
|
||||
Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
|
||||
while ( it.hasNext() ) {
|
||||
Property idProperty = (Property) it.next();
|
||||
if ( localPath.startsWith( idProperty.getName() ) ) return true;
|
||||
if ( localPath.startsWith( idProperty.getName() ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Try the case where a @ManyToOne is also an ID property
|
||||
// E.g. @ManyToOne @Id SomeEntity other;
|
||||
else if ( !path.contains( "." ) ) {
|
||||
KeyValue valueIdentifier = persistentClass.getIdentifier();
|
||||
if ( valueIdentifier instanceof Component ) {
|
||||
Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
|
||||
while ( it.hasNext() ) {
|
||||
Property idProperty = (Property) it.next();
|
||||
if ( path.equals( idProperty.getName() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue