-
Notifications
You must be signed in to change notification settings - Fork 685
Register reflection hints for Querydsl Q types. #2743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduced support for registering GraalVM native reflection type hints for Querydsl Q types that target domain types used in the repository interface declaration. At this point we only do a simple lookup for Q types based in the very same package that implement EntityPath. More advanced configuration (eg. base package and type prefix), potentially available via EntityPathResolver are not taken into account as this would require eager bean resolution from the application context, which is likely to trigger additional infrastructure. In this case the user is required to register Q types manually.
private final static Log logger = LogFactory.getLog(QTypeContributor.class); | ||
private static Function<ClassLoader, Class<?>> entityPathType = cacheOf(QTypeContributor::getEntityPathType); | ||
|
||
public static void contributeEntityPath(Class<?> type, GenerationContext context, @Nullable ClassLoader classLoader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making the entire code conditional based on the presence of com.querydsl.core.types.EntityPath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what happens here, just taking the ClassLoader
into account.
|
||
TypeContributor.contribute(repositoryInformation.getDomainType(), contribution); | ||
QTypeContributor.contributeEntityPath(repositoryInformation.getDomainType(), contribution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check for QTypeContributor.QUERYDSL_PRESENT
or similar.
} | ||
|
||
@Nullable | ||
private static Class<?> getEntityPathType(ClassLoader classLoader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a case where we see multiple class loaders through which we cannot see Querydsl? (Other than testing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use the same class loader that is used for AOT processing.
* @param domainClass | ||
* @return | ||
*/ | ||
private static String getQueryClassName(Class<?> domainClass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a similar computation in our other Querydsl utils. It would make sense to reuse those parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, but that created cycles between the packages.
This commit introduced support for registering GraalVM native reflection type hints for Querydsl Q types that target domain types used in the repository interface declaration. At this point we only do a simple lookup for Q types based in the very same package that implement EntityPath. More advanced configuration (eg. base package and type prefix), potentially available via EntityPathResolver are not taken into account as this would require eager bean resolution from the application context, which is likely to trigger additional infrastructure. In this case the user is required to register Q types manually. Closes: #2721 Original pull request: #2743.
This commit introduced support for registering GraalVM native reflection type hints for Querydsl Q types that target domain types used in the repository interface declaration. At this point we only do a simple lookup for Q types based in the very same package that implement EntityPath. More advanced configuration (eg. base package and type prefix), potentially available via EntityPathResolver are not taken into account as this would require eager bean resolution from the application context, which is likely to trigger additional infrastructure. In this case the user is required to register Q types manually. Closes: #2721 Original pull request: #2743.
This PR introduced support for registering GraalVM native reflection type hints for Querydsl
Q
types that target domain types used in the repository interface declaration.At this point we only do a simple lookup for
Q
types based in the very same package that implementEntityPath
.More advanced configuration (eg. base package and type prefix), potentially available via
EntityPathResolver
are not taken into account as this would require eager bean resolution from the application context, which is likely to trigger additional infrastructure. In this case the user is required to registerQ
types manually.Closes: #2721