QBC查询会根据传入的实体的属性经行查找,当然会忽略主键,关联属性。
User u = new User();
u.setAge(20),
u.setSex("男"),
使用QBC就如同会发送如下sql语句:
select * from user wher age=20 and sex='男';
作用就是根据条件得到相应的实体
public List findByExample(UserForm instance) {
log.debug("finding UserForm instance by example");
try {
List results = hibernateTemplate.findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
在调用的时候直接传递一个UserForm的对象就可以啊
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....