HHH-14071 Fix binding for FetchProfile for OneToOne(mappedBy=...) associations

This commit is contained in:
Oliver Saggau 2020-06-14 15:14:07 +02:00 committed by Sanne Grinovero
parent 33e51c0c47
commit 6027fe1eea
2 changed files with 25 additions and 3 deletions

View File

@ -252,6 +252,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
}
AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, rootMetadataBuildingContext );
AnnotationBinder.bindFetchProfilesForClass( clazz, rootMetadataBuildingContext );
processedEntityNames.add( clazz.getName() );
}
}
@ -301,7 +302,9 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
@Override
public void postProcessEntityHierarchies() {
for ( String annotatedPackage : annotatedPackages ) {
AnnotationBinder.bindFetchProfilesForPackage( annotatedPackage, rootMetadataBuildingContext );
}
}
@Override

View File

@ -349,7 +349,6 @@ public final class AnnotationBinder {
bindQueries( pckg, context );
bindFilterDefs( pckg, context );
bindTypeDefs( pckg, context );
bindFetchProfiles( pckg, context );
BinderHelper.bindAnyMetaDefs( pckg, context );
}
@ -587,7 +586,6 @@ public final class AnnotationBinder {
bindQueries( clazzToProcess, context );
bindFilterDefs( clazzToProcess, context );
bindTypeDefs( clazzToProcess, context );
bindFetchProfiles( clazzToProcess, context );
BinderHelper.bindAnyMetaDefs( clazzToProcess, context );
String schema = "";
@ -1417,6 +1415,27 @@ public final class AnnotationBinder {
}
public static void bindFetchProfilesForClass(XClass clazzToProcess, MetadataBuildingContext context) {
bindFetchProfiles( clazzToProcess, context );
}
public static void bindFetchProfilesForPackage(String packageName, MetadataBuildingContext context) {
XPackage pckg;
try {
pckg = context.getBootstrapContext().getReflectionManager().packageForName( packageName );
}
catch (ClassLoadingException e) {
LOG.packageNotFound( packageName );
return;
}
catch ( ClassNotFoundException cnf ) {
LOG.packageNotFound( packageName );
return;
}
bindFetchProfiles( pckg, context );
}
private static void bindFetchProfiles(XAnnotatedElement annotatedElement, MetadataBuildingContext context) {
FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class );
FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class );