Skip to content

Rewrite String queries for DTO Constructor Expressions #3654

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 10 commits into from
Closed

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Oct 28, 2024

Closes #3076
Closes #2327
Closes #3702

@mp911de mp911de added the type: enhancement A general enhancement label Oct 28, 2024
@mp911de mp911de linked an issue Oct 28, 2024 that may be closed by this pull request
Comment on lines 77 to 90
} else if (obj instanceof FactoryExpression) {
FactoryExpression<?> c = (FactoryExpression<?>) obj;
return args.equals(c.getArgs()) && getType().equals(c.getType());
Copy link
Contributor

@Seol-JY Seol-JY Nov 7, 2024

Choose a reason for hiding this comment

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

Suggested change
} else if (obj instanceof FactoryExpression) {
FactoryExpression<?> c = (FactoryExpression<?>) obj;
return args.equals(c.getArgs()) && getType().equals(c.getType());
} else if (obj instanceof FactoryExpression<?> c) {
return args.equals(c.getArgs()) && getType().equals(c.getType());

I recommend changing the instanceof check to use pattern matching feature.

mp911de and others added 8 commits December 4, 2024 14:32
…e is DTO.

We now rewrite String-based JPA queries to use constructor expressions when either selecting the entity or selecting individual properties.

We do not rewrite queries that already use constructor expressions.

Closes #3076
Also, interface-based projections now use Tuple queries to consistently use tuple-based queries.

Closes #2327
Refactor code duplications.

See #2327
There's a difference in what the query needs to look like using dto vs. interface projections where the former does not allow column aliases and the latter requires them.

See #2327
Simplify Querydsl templates retrieva and String query caching. Update documentation. Skip selection list rewriting if the returned type is an interface.

Encapsulate rewrite information for Query.

Reformat code.

See #2327
Fix reference in javadoc
Introduce constructor compatibility check by checking assingable types.
christophstrobl pushed a commit that referenced this pull request Dec 17, 2024
…e is DTO.

We now rewrite String-based JPA queries to use constructor expressions when either selecting the entity or selecting individual properties.

We do not rewrite queries that already use constructor expressions.

Closes: #3076
Original Pull Request: #3654
christophstrobl pushed a commit that referenced this pull request Dec 17, 2024
Also, interface-based projections now use Tuple queries to consistently use tuple-based queries.

Closes: #2327
Original Pull Request: #3654
christophstrobl pushed a commit that referenced this pull request Dec 17, 2024
See: #2327
Original Pull Request: #3654
christophstrobl added a commit that referenced this pull request Dec 17, 2024
There's a difference in what the query needs to look like using dto vs. interface projections where the former does not allow column aliases and the latter requires them.

See: #2327
Original Pull Request: #3654
christophstrobl pushed a commit that referenced this pull request Dec 17, 2024
Simplify Querydsl templates retrieve and String query caching. Update documentation. Skip selection list rewriting if the returned type is an interface.

Encapsulate rewrite information for Query.

Reformat code.

See: #2327
Original Pull Request: #3654
christophstrobl added a commit that referenced this pull request Dec 17, 2024
Also fix a broken reference in javadoc.

Original Pull Request: #3654
christophstrobl pushed a commit that referenced this pull request Dec 17, 2024
Introduce constructor compatibility check by checking assignable types.

Original Pull Request: #3654
@christophstrobl christophstrobl deleted the issue/3076 branch December 17, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
3 participants