Hibernate 的 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

你可能感兴趣的:(Hibernate,String,user,Class,getter,setter)