日期:2014-05-17  浏览次数:20758 次

HIbernate 的QBE问题,多对一的表,为什么不能正确查询???是单项映射的
public List findEmployees(Employee employee, Company company) throws HibernateException {
Example exampleEmployee = Example.create(employee);
exampleEmployee.enableLike(MatchMode.ANYWHERE);
exampleEmployee.excludeZeroes();


Example exampleCompany = Example.create(company);
exampleCompany.enableLike(MatchMode.ANYWHERE);
exampleCompany.excludeZeroes();

Session session=hibernateTemplate.getSessionFactory().getCurrentSession();
Criteria criteria=session.createCriteria(Employee.class)
.add(exampleEmployee);
.createCriteria("company")
.add(exampleCompany);

Iterator iterator = criteria.list().iterator();
while(iterator.hasNext()) {

System.out.println(iterator.next()+"+++");  

}
return criteria.list() ;
}

------解决方案--------------------
不能正确查询是什么意思,还有,你是通过多找1还是1找多