Search code examples
javahibernateplayframeworkjpql

JPQL where in array query


I'm trying to update every record for which I have the id in my arraylist but I'm getting this error:

IllegalStateException occured : org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations [update models.UserOnline uo SET currentRoom_id = :roomid where uo.id IN (:list)]

This is what I'm trying:

    Query update_query = JPA.em().createQuery("update UserOnline uo SET currentRoom_id = :roomid where uo.id IN (:list)");
    update_query.setParameter("roomid", null);
    update_query.setParameter("list", idlist);

    List<UserOnline> actual = update_query.getResultList();

Any ideas what's wrong?


Solution

  • I would try with update_query.executeUpdate();

    From the docs.