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

Update JPQL and HQL parsers with newly introduced JPA 3.2 keywords #3136

Closed
Tracked by #3673 ...
mp911de opened this issue Sep 1, 2023 · 6 comments · May be fixed by #3526
Closed
Tracked by #3673 ...

Update JPQL and HQL parsers with newly introduced JPA 3.2 keywords #3136

mp911de opened this issue Sep 1, 2023 · 6 comments · May be fixed by #3526
Assignees
Labels
type: enhancement A general enhancement

Comments

@mp911de
Copy link
Member

mp911de commented Sep 1, 2023

See https://deploy-preview-652--jakartaee-specifications.netlify.app/specifications/persistence/3.2/

  • Adds union, intersect, except, cast, left, right, and replace for Jakarta Persistence QL and criteria queries
  • Adds || string concatenation operator to Jakarta Persistence QL
  • Adds support for specifying null precedence when ordering Jakarta Persistence QL and criteria queries
@Nendanfito
Copy link

Nendanfito commented Jun 5, 2024

Does null precedence work on Page requests? Because its not working for me with version 3.2.1

Sort.Order sort = switch (direction != null ? direction : "") {
            case "asc" -> Sort.Order.asc(sortBy);
            case "desc" -> Sort.Order.desc(sortBy).nullsLast();
            default -> Sort.Order.asc("code");
        };

PageRequest pageRequest = PageRequest.of(
                alarmPageableFilter.getPageNumber(),
                alarmPageableFilter.getPageSize(),
                Sort.by(sort));

Page<Alarm> page = alarmRepository.findAll(getByFilter(alarmPageableFilter), pageRequest);

@mp911de
Copy link
Member Author

mp911de commented Jun 6, 2024

No, it's not working with 3.2.1 because the JPA spec level is at 3.1. Starting with JPA 3.2, the API will specify null precedence (see https://projects.eclipse.org/projects/ee4j.jpa/releases/3.2)

@ducanh2110
Copy link

I have the same issue too. Dont understand why it's happen

@joseardaiz
Copy link

@mp911de and @christophstrobl - would you guys know when the issue that @Nendanfito explained here will be fixed?

@emaranga
Copy link

emaranga commented Nov 5, 2024

Does null precedence work on Page requests? Because its not working for me with version 3.2.1

Sort.Order sort = switch (direction != null ? direction : "") {
            case "asc" -> Sort.Order.asc(sortBy);
            case "desc" -> Sort.Order.desc(sortBy).nullsLast();
            default -> Sort.Order.asc("code");
        };

PageRequest pageRequest = PageRequest.of(
                alarmPageableFilter.getPageNumber(),
                alarmPageableFilter.getPageSize(),
                Sort.by(sort));

Page<Alarm> page = alarmRepository.findAll(getByFilter(alarmPageableFilter), pageRequest);

Did you find a workaround?

@Nendanfito
Copy link

@emaranga I configured it for spring in general in the application.yaml:

spring:
  jpa:
    properties:
      hibernate:
        order_by:
          default_null_ordering: last

With that solution all the querys made by jpa will return nulls last, in case you don't want it you have to made a nativeQuery.

@mp911de mp911de mentioned this issue Nov 13, 2024
5 tasks
@mp911de mp911de self-assigned this Nov 25, 2024
@mp911de mp911de added this to the 4.0 M1 (2025.1.0) milestone Nov 25, 2024
mp911de pushed a commit that referenced this issue Nov 27, 2024
mp911de pushed a commit that referenced this issue Nov 29, 2024
mp911de pushed a commit that referenced this issue Nov 29, 2024
@mp911de mp911de mentioned this issue Nov 29, 2024
5 tasks
mp911de pushed a commit that referenced this issue Dec 11, 2024
mp911de pushed a commit that referenced this issue Dec 11, 2024
christophstrobl pushed a commit that referenced this issue Dec 20, 2024
christophstrobl added a commit that referenced this issue Dec 20, 2024
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
Development

Successfully merging a pull request may close this issue.

6 participants