下面的代码段,
@Entity
public class A {
@Id@GeneratedValue private Long id;
private String name;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
...
tx.begin();
em.persist(new A());
tx.commit();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaUpdate<A> update = cb.createCriteriaUpdate(A.class);
Root<A> a = update.from(A.class);
ParameterExpression<String> param = cb.parameter(String.class);
tx.begin();
em.createQuery(update.set(a.<String> get("name"), "julie")).executeUpdate();
tx.commit();
tx.begin();
em.createQuery(update.set(a.<String> get("name"), param))
.setParameter(param, "joe").executeUpdate();
tx.commit();
Query#setParameter
始终从IllegalArgumentException
下方Hibernate-entitymanager(5.2.8.Final)
退出,Eclipselink(2.6.4)
也遇到类似问题。
java.lang.IllegalArgumentException: Could not resolve binding for given parameter reference
[org.hibernate.query.criteria.internal.expression.ParameterExpressionImpl...]
@EDIT
#setParameter
的测试,该测试已通过。