I am new to Hibernate and based upon the documentation for native query, I expected following code to execute.
public boolean markStatusById(List<Integer> list, String newStatus) throws Exception {
boolean statusUpdated = false;
try {
entityManager.createQuery("UPDATE MyTableEntity SET status = :newStatus WHERE my_table_id in (?1)",
MyTableEntity .class)
.setParameter(newStatus, newStatus)
.setParameter(1, list);
statusUpdated = true;
} catch (IllegalArgumentException | TransactionRequiredException e) {
throw new Exception(CLASS_NAME,"markStatusById", e);
}
return statusUpdated;
}
However, for some reason, this does not work.
What is the correct way to achieve what is intended in above query. One of My Reference