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

Rewrite String queries for DTO Constructor Expressions #3654

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Oct 28, 2024

Closes #3076
Closes #2327

@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
…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.
Also, interface-based projections now use Tuple queries to consistently use tuple-based queries.
Refactor code duplications.
Comment on lines +77 to +79
} 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.

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
2 participants