Skip to content

Align AOT and reflective repository behavior. #5038

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

Closed
wants to merge 12 commits into from
Closed

Conversation

christophstrobl
Copy link
Member

Closes: #5027

@christophstrobl christophstrobl requested a review from mp911de August 8, 2025 07:24
builder.addStatement("stages.add(new $T($S, $L))", Document.class, "$sort",
context.localVariable("sortDocument"));

if (outputType == Document.class || MongoSimpleTypes.HOLDER.isSimpleType(outputType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MongoRepositoryContributor uses a MongoMappingContext. Ideally, we use its SimpleTypeHolder for further introspection to use a consistent configuration source.


private static Class<?> getOutputType(MongoQueryMethod queryMethod) {
Class<?> outputType = queryMethod.getReturnedObjectType();
if (MongoSimpleTypes.HOLDER.isSimpleType(outputType)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use SimpleTypeHolder from MongoRepositoryContributor.

@@ -52,7 +53,7 @@ static Placeholder indexed(int position) {
* @param type
* @return
*/
public static Shape geoJson(int index, String type) {
static Shape geoJson(int index, String type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I liked to keep public in package-protected types to indicate a method is intended to be used as sort-of a public API (entrypoint) for other callers outside of the class. In any case, just a thought.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have them aligned with the type scope in such cases.

@@ -157,12 +179,34 @@ static class PlaceholderParameterAccessor implements MongoParameterAccessor {

private final List<Object> placeholders;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, in JPA we've introduced a concept of ParameterBinding definining BindingIdentifier (named/indexed identifier within the query) and ParameterOrigin (Expression, MethodInvocationArgument, Synthetic).

ParameterBinding can be an In or Like binding to carry around information about post-processing of the binding. I have the impression that MongoDB could benefit from such an arrangement as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently we're missing the link between the parameter and part tree part, so we'd have to introduce that first. I agree that having it would make things easier to follow. Should we do it in a next step?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. For now, we can use the current approach.

@mp911de mp911de added type: enhancement A general enhancement theme: aot An issue related to Ahead-Of-Time processing labels Aug 11, 2025
@mp911de mp911de added this to the 5.0 M5 (2025.1.0) milestone Aug 11, 2025
@mp911de mp911de marked this pull request as ready for review August 11, 2025 06:30
mp911de pushed a commit that referenced this pull request Aug 11, 2025
mp911de pushed a commit that referenced this pull request Aug 11, 2025
mp911de added a commit that referenced this pull request Aug 11, 2025
Reformat code. Use existing SimpleTypeHolder instead of static MongoSimpleTypes.

See: #5027
Original pull request: #5038
@mp911de mp911de self-assigned this Aug 11, 2025
@mp911de mp911de closed this Aug 11, 2025
@mp911de mp911de deleted the issue/5027 branch August 11, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-Of-Time processing type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix AOT vs reflective behavior failures in AotPersonRepositoryIntegrationTests
2 participants