0
我正在使用Hibernate Criteria
从我的表中的列mobileno
获取最大值。Hibernate(not JPA)Criteria - org.hibernate.QueryException:无法解析属性:
但是,当我得到的结果,它抛出一个异常
org.hibernate.QueryException: could not resolve property: mobileno of:
我的表bean属性是:
@Column(name="id")
private long id;
@Column(name="code")
private String code;
@Column(name="mobileno")
private String mobileno;
//Setters and Getters
Hibernate代码:
@Override
public long getMaxMobileNo() {
Session session = entityManager.unwrap(Session.class);
Criteria criteria = session.createCriteria(Data.class);
criteria.setProjection(Projections.max("mobileno"));
return (long) criteria.uniqueResult();
}
我在哪里出错了,我如何从我的表中获得最大值?
“字符串”类型的“最大”? – nobeh
@nobeh:是的。那就是问题所在? – user7646838
Projections.max =属性最大值。非常重要的是,mobileno的最大价值是什么?我不知道预测,但似乎是数值。 – Nico