我有以下内容:
@Entity
public class Person {
@Id
private long id;
@Column
private String firstName;
// getters and setters
}
我希望以下工作:
Criteria criteria = session.createCriteria(Person.class);
criteria.add(Restrictions.eq("firstName", "john"));
OR
criteria.add(Restrictions.eq("FIRSTNAME", "john"));
OR
criteria.add(Restrictions.eq("fiRstName", "john"));
基本上,我有一个允许过滤后端对象的 Web 服务,我们试图忽略属性名称中的大小写。我不知道该怎么做。我搜索并查看了休眠文档和休眠源,但一无所获。Hibernate 的例外是
org.hibernate.QueryException: could not resolve property FIRSTNAME (or fiRstName) of com.abc.Person
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1482)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:62)
at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1457)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:483)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.findColumns(CriteriaQueryTranslator.java:498)
at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:68)