Criteria criteria = session.createCriteria(Account.class);
criteria.add(Expression.eq("accountProfile.homeAddress.province",address.getProvince()));
其中Account类中有AccountProfile属性,AccountProfile有homeAddress属性,Address有province属性。
其中Account类中有AccountProfile属性,AccountProfile有homeAddress属性,Address有province属性。
accountProfile.homeAddress.province写法是HQL方式,是对象概念在过程平台中的变相表达方式,类似OGNL
Criteria是对象方式查询,可使用setFetchMode FetchMode.JOIN方式
http://www.devarticles.com/c/a/Java/Hibernate-Criteria-Queries-in-Depth/
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: homeAddress of: com.sns.xmu.model.Account; nested exception is org.hibernate.QueryException: could not resolve property: homeAddress of: com.sns.xmu.model.Account
Account与AccountProfile是一对一的关联。