Spring JPA Data Order with NullHandling (Postgres)

I have a problem with NullHandling in Spring Data. I am trying to pass custom NullHandling to my findAll repository method - something like below:

Page<Developer> developerPage = developerRepository.findAll( new PageRequest(0, 2, new Sort(new Sort.Order(Sort.Direction.ASC, "user").nullsFirst())) ); 

However, I have the show-sql option set to true, and in the logs I see that nothing is said about the zero processing in the query that is passed to the database. I get the wrong results (even more different results for Postgres and H2, but I understand that this is the difference between the default processing for each database). Configuration for Postgres:

 spring.datasource.driverClassName=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://localhost/postgres?useUnicode=yes&characterEncoding=UTF-8 spring.datasource.username=postgres spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.properties.hibernate.globally_quoted_identifiers=true spring.jpa.show-sql=true spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 

What is the problem? Is custom nulling supported in Spring Data JPA?

Edit:

I found out that part of the request order for JPA is created in the QueryUtils class in the toOrders (..) method. Interestingly, Sorting from Spring data is mapped to sort the JPA implementation, where there is no support for zero processing. There is also a problem with jira that describes that it is not supported, but since 2014: https://jira.spring.io/browse/DATACMNS-491

+5
source share

Source: https://habr.com/ru/post/1266833/


All Articles