Java 在(List<;Long>;id)中执行findBy[NAME]时,SPRING JPA使用eclipse链接POSTGRESQL时出错
当我试图使用findByIdIn(List-id)时,我的springjparepository类遇到了一个问题,例如我想将一个id列表传递给本机查询,并期望它返回一个对象列表 马文副总裁:Java 在(List<;Long>;id)中执行findBy[NAME]时,SPRING JPA使用eclipse链接POSTGRESQL时出错,java,spring,postgresql,jpa,eclipselink,Java,Spring,Postgresql,Jpa,Eclipselink,当我试图使用findByIdIn(List-id)时,我的springjparepository类遇到了一个问题,例如我想将一个id列表传递给本机查询,并期望它返回一个对象列表 马文副总裁: spring数据jpa 1.4.2 org.eclipse.persistence.jpa2.5.1 DB: PostgreSQL 9.3 应用服务器: 玻璃鱼4.0 这是我的存储库类 @Repository public interface TransactionRepository exte
- spring数据jpa 1.4.2
- org.eclipse.persistence.jpa2.5.1
- PostgreSQL 9.3
- 玻璃鱼4.0
@Repository
public interface TransactionRepository extends JpaRepository<Transaction, Long>, QueryDslPredicateExecutor<Transaction> {
List<Transaction> findByIdIn(List<Long> ids);
}
如果我将SQL复制/粘贴到我的管理工具中,它就可以正常工作
---编辑---
非常感谢您在这方面的帮助
“问候”看起来像个虫子。请参见此处:和此处:在
交易
实体上的id
字段的类型是什么?使用id def为字段编辑的帖子数据库中的id
的类型是什么?您可以尝试更改一次JPA提供者吗?像Hibernate或OpenJPA?数据库字段是bigint。有解决方法吗?我可以写一个JPQL查询吗?
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: 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: 160
Error Code: 0
Call: SELECT ID, amount, comment, created_date, currency, status, transaction_step, transaction_type, version, provider_id, user_id FROM anix.transactions WHERE (ID IN ((?,?)))
bind => [2, 3]
Query: ReadAllQuery(referenceClass=Transaction sql="SELECT ID, amount, comment, created_date, currency, status, transaction_step, transaction_type, version, provider_id, user_id FROM anix.transactions WHERE (ID IN (?))")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:682)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
@Entity
@Table(name = "transactions", schema = "anix")
@XmlRootElement
@XmlAccessorType(FIELD)
public class Transaction implements Serializable {
@Id
@SequenceGenerator(name = "transactions_sequence", sequenceName = "transactions_id_seq", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = SEQUENCE, generator = "transactions_sequence")
@XmlID
@XmlElement
private Long id;