当前位置: 首页 > 图文教程 > Java技术 > 数据库持久层 > hibernate的findByExample
数据库持久层 中的 hibernate的findByExample
用了这么长时间的hibernate/spring,如果不是今天用的findByExample方法到现在还不知道findByExample的机制。惭愧
Class User{
String username;
String password = "默认口令";
Company company;
getter()&setter().....
}
Company company = companyDao.getById("id");
User user = new User();
user.setSid("主键");
uer.setUsername("user");
use.setCompany(company);
userDao.findByExample(user);
这个时候的SQL条件为:
select * from user
where username = ?
and password = ?
findByExample()使用时得出结论:
1.不支持主键
2.不支持关联
3.不支持NULL
评论 (0) All