Skip to content

Commit

Permalink
HHH-14467 Simplify detection of *ToOne associations that are part of …
Browse files Browse the repository at this point in the history
…the entity identifier
  • Loading branch information
gbadner authored and yrodiere committed Mar 1, 2021
1 parent b6b8353 commit 021b274
Showing 1 changed file with 8 additions and 18 deletions.
Expand Up @@ -67,29 +67,19 @@ else if ( property != null) {
return path.startsWith( property.getName() + "." );
}
//try the embedded property
//embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
else if ( path.startsWith( "id." ) ) {
KeyValue valueIdentifier = persistentClass.getIdentifier();
String localPath = path.substring( 3 );
else {
final KeyValue valueIdentifier = persistentClass.getIdentifier();
if ( valueIdentifier instanceof Component ) {
Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
while ( it.hasNext() ) {
Property idProperty = (Property) it.next();
if ( localPath.startsWith( idProperty.getName() ) ) {
return true;
}
// Embedded property starts their path with 'id.'
// See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
String localPath = path;
if ( path.startsWith( "id." ) ) {
localPath = path.substring( 3 );
}
}
}
// 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() ) ) {
if ( localPath.startsWith( idProperty.getName() ) ) {
return true;
}
}
Expand Down

0 comments on commit 021b274

Please sign in to comment.