Hibernate repo中的自定义查询

时间:2016-10-06 12:42:40

标签: java postgresql hibernate

我收到以下产品的最后价格:

ProductPrice findFirstByProductIdOrderByDateFromDesc(@Param(value = "product") Long product);

但是,现在我试图将产品ID列表作为参数传递。

我有以下内容:

List<ProductPrice> findAllFirstByProductIdOrderByDateFromDesc(@Param(value = "product")List<Long> products);

执行时抛出:

2016-10-06 14:41:17,130 WARN o.h.e.j.s.SqlExceptionHelper: SQL Error: 0, SQLState: 42883
2016-10-06 14:41:17,130 ERROR o.h.e.j.s.SqlExceptionHelper: ERROR: operator does not exist: bigint = record
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 7207
2016-10-06 14:41:17,148 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = record
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 7207

任何想法我做错了什么?

1 个答案:

答案 0 :(得分:0)

尝试IN

List<ProductPrice> findByProductIdInOrderByDateFromDesc(@Param(value = "product")List<Long> products);
相关问题