Example usage for javax.persistence.criteria CriteriaUpdate set

List of usage examples for javax.persistence.criteria CriteriaUpdate set

Introduction

In this page you can find the example usage for javax.persistence.criteria CriteriaUpdate set.

Prototype

CriteriaUpdate<T> set(String attributeName, Object value);

Source Link

Document

Update the value of the specified attribute.

Usage

From source file:com.toptal.dao.UserDaoImpl.java

@Transactional
@Override//from  w  w  w .j  a  v  a2  s.  co  m
public final User saveIgnoringPassword(final User user) {
    final CriteriaBuilder builder = this.manager.getCriteriaBuilder();
    final CriteriaUpdate<User> update = builder.createCriteriaUpdate(User.class);
    final Root<User> root = update.from(User.class);
    update.set(root.get(NAME_FIELD), user.getName());
    update.set(root.get("role"), user.getRole());
    update.where(builder.equal(root.get("id"), user.getId()));
    this.manager.createQuery(update).executeUpdate();
    return this.manager.find(User.class, user.getId());
}