I try to make an application with Spring-Data-JPA on a table in order by ASC but it gives me an error:
我试图按照ASC的顺序在表上创建一个带有Spring-Data-JPA的应用程序,但它给了我一个错误:
Invalid derived query! No property asc found for type java.util.Calendar
Why ?
为什么?
List<Foo> findAllOrderByDateAsc();
or
或
@Query("SELECT * FROM foo ORDER BY date ASC")
List<Foo> findAllOrderByDateAsc();
3 个解决方案
#1
90
Try to add "By" between "All" and "Order" like this:
试着在“All”和“Order”之间加上“By”,就像这样:
List<Foo> findAllByOrderByDateAsc();
#2
8
I don't think you can use findAll as a prefix.
我认为您不能使用findAll作为前缀。
Regarding the query, select *
is not valid JPQL. It should be
对于查询,select *不是有效的JPQL。它应该是
select foo from Foo foo order by foo.date desc
#3
1
date
is reserved word in SQL. Try changing the table property to foo_date
, for example and rewrite your query as SELECT * FROM foo ORDER BY foo_date DESC
日期是SQL中的保留字。例如,尝试将表属性更改为foo_date,并通过foo_date DESC将查询重写为SELECT * FROM foo ORDER
#1
90
Try to add "By" between "All" and "Order" like this:
试着在“All”和“Order”之间加上“By”,就像这样:
List<Foo> findAllByOrderByDateAsc();
#2
8
I don't think you can use findAll as a prefix.
我认为您不能使用findAll作为前缀。
Regarding the query, select *
is not valid JPQL. It should be
对于查询,select *不是有效的JPQL。它应该是
select foo from Foo foo order by foo.date desc
#3
1
date
is reserved word in SQL. Try changing the table property to foo_date
, for example and rewrite your query as SELECT * FROM foo ORDER BY foo_date DESC
日期是SQL中的保留字。例如,尝试将表属性更改为foo_date,并通过foo_date DESC将查询重写为SELECT * FROM foo ORDER