I'm trying to perform a bulk update with JPA 2.1 CriteriaUpdate in Hibernate 4.3.0.GA, but have not found how to set a field to null.
The code is structured like this - I'd like to set a nullable field back to null.
CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaUpdate<User> q = cb.createCriteriaUpdate(User.class); Address nullAddress = null; q.set(PushUser_.altAddress, nullAddress); Root<User> userRoot = q.from(User.class); q.where(userRoot.get(User_.userId).in(userIdList)); int count = em.createQuery(q).executeUpdate();
I get this exception from the q.set() call setting null: Exception in thread "Thread-1" java.lang.NullPointerException at org.hibernate.jpa.criteria.CriteriaUpdateImpl.set(CriteriaUpdateImpl.java:87)
What's the correct way to do this?
|