I want to delete the records from a PGSQL database table(ContainerTypeRule) whose id(rule_id) is greater than 10000. I am creating a query in JPA like as follows
public void deleteAllTestRules(long startID){
em.createQuery("DELETE FROM ContainerTypeRule WHERE rule_id > ?startID", ContainerTypeRule.class)
.setParameter("startID", startID)
.executeUpdate();
}
But I am getting the error like this.
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing [DELETE FROM ContainerTypeRule WHERE rule_id > ?startID].
[46, 54] The positional input parameter ''{0}'' cannot use non-Integer characters.
How can I formulate correct query for 'id greater than 10000' condition in my JPA query.
You must use: not?
DELETE FROM ContainerTypeRule WHERE rule_id > :startID
You can either use positional parameters and use '?' . ex: DELETE FROM ContainerTypeRule WHERE rule_id >:startID
Or you can use named parameters and use ':' . ex: DELETE FROM ContainerTypeRule WHERE rule_id >?1
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.