I have an Entity who has a boolean
property.
class MyEntity {
@Basic(optional = false)
@Column(name = "FLAG")
private boolean flag;
}
How can I execute a bulk update setting the flag
field with true
?
// UPDATE MyEntity AS e SET e.flag = TRUE
final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
final CriteriaUpdate<MyEntity> update
= builder.createCriteriaUpdate(MyEntity.class);
final Root<MyEntity> root = criteriaUpdate.from(MyEntity.class);
update.set(root.get(ProfileClue_.flag), ???);
Using pure JPA I would do something like
Using a more advanced JPA provider that supports parameters in other parts of the query than the JPA spec mandates (supported by DataNucleus JPA, and maybe others), you can make it a parameter.