-
Notifications
You must be signed in to change notification settings - Fork 869
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
[#658] Support JPQL Treated paths for WHERE clause #2530
[#658] Support JPQL Treated paths for WHERE clause #2530
Conversation
@idosal could you review this one? 😄 |
Sure, I'll get on it soon. Sorry for the delay, it kind of fell between the cracks. |
querydsl-jpa/src/main/java/com/querydsl/jpa/JPAExpressions.java
Outdated
Show resolved
Hide resolved
* @param <T> the expression type | ||
* @return subtype instance with the same identity | ||
*/ | ||
public static <U extends BeanPath<? extends T>, T> U treat(BeanPath<? extends T> path, Class<U> subtype) { |
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.
@johnktims Apprently this is now considered a breaking change:
Class com.querydsl.jpa.JPAExpressions
Added Method treat, sig <U:Lcom/querydsl/core/types/dsl/BeanPath<+TT;>;T:Ljava/lang/Object;>(Lcom/querydsl/core/types/dsl/BeanPath<+TT;>;Ljava/lang/Class<TU;>;)TU;, desc (Lcom/querydsl/core/types/dsl/BeanPath;Ljava/lang/Class;)Lcom/querydsl/core/types/dsl/BeanPath;, access public static
[WARNING] Rule 0: org.semver.enforcer.RequireBackwardCompatibility failed with message:
Current codebase is not backward compatible (BACKWARD_COMPATIBLE_USER) with version <4.3.2-20200601.233131-46>. Compatibility type has been detected as <NON_BACKWARD_COMPATIBLE>
How should we resolve this? Bump the snapshot version? Move the method to a new class? Add some sort of surpression?
JPA 2.1 introduced the TREAT operator for explicit casting. Initial support for TREAT in the FROM clause was added in PR #705. However, the specification also describes the notion of `treated_subpath` expressions (chapter 4.4.4.1) that are allowed in the WHERE clause of a query. The syntax is as follows: > ``` > treated_subpath ::= TREAT(general_subpath AS subtype) > > single_valued_path_expression ::= qualified_identification_variable | TREAT(qualified_identification_variable AS subtype) | state_field_path_expression | single_valued_object_path_expression > ``` And can be used as such: ```SQL SELECT e FROM Employee e JOIN e.projects p WHERE TREAT(p AS LargeProject).budget > 1000 ``` (Example from chapter 4.4.9). This pull request adds the support for treated subpaths in QueryDSL. It does so by introducing a new `PathType` and convenience method `JPAExpressions.treat`.
JPA 2.1 introduced the TREAT operator for explicit casting. Initial support for TREAT in the FROM clause was added in PR #705. However, the specification also describes the notion of
treated_subpath
expressions (chapter 4.4.4.1) that are allowed in the WHERE clause of a query.The syntax is as follows:
And can be used as such:
(Example from chapter 4.4.9).
This pull request adds the support for treated subpaths in QueryDSL. It does so by introducing a new
PathType
and convenience methodJPAExpressions.treat
.Fixes #658
A full list of treat support throughout JPA providers can be found at https://github.com/beikov/jpa-treat-variations