I got a problem with my SPRING JpaRepository class when trying to use the findByIdIn(List ids), eg i want to pass a list of ids to the native query and expect it to return a list of objects.
Maven dep.:
- spring-data-jpa 1.4.2
- org.eclipse.persistence.jpa 2.5.1
DB:
- PostgreSQL 9.3
Appserver:
- Glassfish 4.0
Here is my repository class
@Repository
public interface TransactionRepository extends JpaRepository<Transaction, Long>, QueryDslPredicateExecutor<Transaction> {
List<Transaction> findByIdIn(List<Long> ids);
}
Field id in database is BIGINT.
When I pass ONLY 1 object in the list it works, when it's 0 or more than 1 object in the list I receive this error:
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)
The SQL works fine in my admin tool if I copy/paste it there.
--- EDIT ---
@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;
Would appreciate any help on this!
Regards