public List findByExample(Farms instance) {
log.debug("finding Farms instance by example");
try {
List results = getSession().createCriteria("com.base.Farms")
.add(Example.create(instance)).list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
Example example = Example.create(cat)
.excludeZeroes() //排除值为0的属性
.excludeProperty("color") //排除 color属性
.ignoreCase() //忽略大小写
.enableLike(); //启用模糊查询
List results = session.createCriteria(Cat.class)
.add(example)
.list();
findByExample()使用时得出结论:
1.不支持主键
2.不支持关联
3.不支持NULL