D
D
DDwrt1002019-07-16 15:12:51
Java
DDwrt100, 2019-07-16 15:12:51

How to make a conditional query in a List in JPA?

Good afternoon, please tell me how to make a query to the database.
I get as input a List of parameters id operators .
Now I need to make a request through JPA, I need to select all the records that contain the received id.
now I have a custom request

@Query(value = "FROM Task WHERE (Tasksid = null) AND  Operator = :OperatorIds")
    Set<Task> qualityTaskWIthoutCOmparsionId(@Param("OperatorIds") List<Long>  OperatorIds);

org.postgresql.util.PSQLException
: ERROR: operator does not exist: bigint = bytea
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
How can I build a query correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Israpil Akhmedov, 2019-07-16
@DDwrt100

Operator IN :OperatorIds

@
@mswindu, 2019-08-05
_

As mentioned above, you need to use the following code

@Query(value = "FROM Task WHERE (Tasksid = null) AND Operator IN (:OperatorIds)")
Set<Task> qualityTaskWIthoutCOmparsionId(@Param("OperatorIds") List<Long>  OperatorIds);

And the error
org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = bytea
appears most likely due to the fact that null comes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question