Skip to content
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

Support generic query type mappings in TypeMapping (fixes #2561) #2562

Merged
merged 1 commit into from Jul 27, 2020
Merged

Support generic query type mappings in TypeMapping (fixes #2561) #2562

merged 1 commit into from Jul 27, 2020

Conversation

jwgmeligmeyling
Copy link
Member

@jwgmeligmeyling jwgmeligmeyling commented Apr 12, 2020

Type parameters may be declared for SimpleType, but in the determination of the query type it is always looked up by raw type.

Types may be extended for the support of custom expressions. For example querydsl-spatial does this with the GeometryType:

for (Map.Entry<String, String> entry : additions.entrySet()) {
    typeMappings.register(
            new SimpleType("org.geolatte.geom." + entry.getKey()),
            new SimpleType("com.querydsl.spatial." + entry.getValue()));
}

However, due to the limitation described above, extensions are not able to specify specific path implementations for different bounds, or for example pass on the generic bound to the path expression, like:

  • SomeGenericClass<Integer> -> SomeGenericPath<Integer>
  • SomeGenericClass<Long> -> SomeGenericPath<Long>

Because the mapping is based on raw class name, the latter will override the previous binding, and SomeGenericPath<Long> will be used for both types.

Fixes #2561

This feature is useful for implementing custom types. A proof of concept can be seen in my https://github.com/jwgmeligmeyling/hibernate-types-querydsl-apt repository.

jwgmeligmeyling referenced this pull request in jwgmeligmeyling/hibernate-types-querydsl-apt Apr 12, 2020
@jwgmeligmeyling
Copy link
Member Author

@idosal Could you have a look at this one as well? 😄

@jwgmeligmeyling jwgmeligmeyling self-assigned this May 24, 2020
@johnktims johnktims added this to the 4.3.2 milestone May 27, 2020
@jwgmeligmeyling jwgmeligmeyling merged commit 4204626 into querydsl:master Jul 27, 2020
@jwgmeligmeyling jwgmeligmeyling deleted the issue/2561 branch July 27, 2020 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support generic query type mappings in TypeMappings
3 participants