Transaction required exception on execute update for JPQL update query
I get this error when I try to run this code. Error: javax.persistence.TransactionRequiredException: executeUpdate is not supported for a Query object obtained through non-transactional access of a container-managed transactional EntityManager Code: (_ut is a UserTransaction object) public void setMainCategory(Integer deptId, Integer catId) { try { Query setmain = _entityManager.createNamedQuery("Category.setAsMain"); Query removeMain = _entityManager.createNamedQuery("Category.removeMain"); setmain.setParameter("categoryId", catId); Department d; d=_entityManager.find(Department.class, deptId