简体   繁体   中英

IN clause inside an update query, using JPQL

i'm trying to execute this query:

    @Modifying
@Transactional
@Query(value = "UPDATE SpreadsheetRegisters r SET r.buApprobation =1 WHERE r.idRegister IN (:list)")
public void updateExpiredRegistries(@Param("list") List<BigDecimal> expiredRegistriesIds);

Basically, i'm trying to update a entity if her id is inside that list.

This is the exception i'm getting:

o.h.engine.jdbc.spi.SqlExceptionHelper   : ORA-00936: missing expression

org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement

It seems that my query is wrong, but i don't know where... Anyone can help me ? thx

Your entity class must be called “SpreadsheetRegisters” as you are using the query annotation. However, you can set the the native property of the @Query to be true if you want to use the database table name rather than the entity class name

It's ok to keep the brackets, leave them.

Thank you guys for your support. After some hours i discovered the error. The query was right, but my list no, she was empty, and because of that the database couldn't do his work.

JPA: 1 Me: 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM