2013-12-17 19 views
2

時使用Eclipse鏈接POSTGRESQL的SPRING JPA錯誤嘗試使用findByIdIn(List ID)時,我的SPRING JpaRepository類出現問題,例如我想傳遞一個列表的id到本地查詢,並期望它返回一個對象列表。在執行findBy [名稱] In(列表<Long> ID)

Maven的DEP:

  • 彈簧數據JPA 1.4.2
  • org.eclipse.persistence.jpa 2.5.1

DB:

  • 的PostgreSQL 9.3

APPSERVER:

  • Glassfish的4.0

這裏是我的倉庫類數據庫

@Repository 
public interface TransactionRepository extends JpaRepository<Transaction, Long>, QueryDslPredicateExecutor<Transaction> { 

    List<Transaction> findByIdIn(List<Long> ids); 
} 

字段ID爲BIGINT。

當我傳球只有1個對象在它的工作原理,當它的0或列表中的超過1名對象名單我收到此錯誤:

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) 

的SQL工作正常,在我的管理工具,如果我複製/粘貼在那裏。

---編輯---

@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; 

將不勝感激任何幫助!

Regards

+0

什麼是'交易'實體上'id'字段的類型? –

+0

用id-def編輯後的字段 – user3110615

+0

數據庫中數據庫中的id是什麼類型? –

回答