Files
spring-data-demo/pagination/output/04-sorting.txt
T

22 lines
1.6 KiB
Plaintext

# derived query, Sort.by("price").descending().and(Sort.by("id"))
select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where p1_0.category=? order by p1_0.price desc,p1_0.id fetch first ? rows only
# derived query, unknown property
org.springframework.data.core.PropertyReferenceException
No property 'nope' found for type 'Product'; Did you mean 'name'
# @Query with Sort.by("price").descending() (alias p is applied for you)
select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where p1_0.category=? order by p1_0.price desc fetch first ? rows only
select count(*) from product p1_0 where p1_0.category=?
# a value that is not a property reference at all: Sort.by("price) desc, (select 1")
derived -> InvalidDataAccessApiUsageException
Sort expression 'price) desc, (select 1: ASC' must only contain property references or aliases used in the select clause; If you really want to use something other than that for sorting, please use JpaSort.unsafe(…)
@Query -> InvalidDataAccessApiUsageException
Sort expression 'price) desc, (select 1: ASC' must only contain property references or aliases used in the select clause; If you really want to use something other than that for sorting, please use JpaSort.unsafe(…)
# @Query with a function-style sort value, three calls in one fresh context
1. Sort.by("length(name)") -> rejected (InvalidDataAccessApiUsageException)
2. JpaSort.unsafe("length(name)") -> accepted: order by character_length(p1_0.name) fetch first ? rows only
3. Sort.by("length(name)") again -> accepted: order by character_length(p1_0.name) fetch first ? rows only