hibernateTemplate关于findByExample对entity类型的识别

findByExample()使用时得出结论:
1.不支持主键
2.不支持关联
3.不支持NULL
4.对于基本类型(char,int。。。。)将会默认作为查询条件
如:
@Entity
@Table
public class User{
private int id;
private String name;
private String pwd;
private int age;
//getter/setter.....


public void UserDaoImpl(){
......
User u=new User();
u.set(name);
u.set(pwd);
[color=red]//注意没有给age赋值[/color]
this.hibernateTemplate.findByExample(u);

}

[color=darkblue]其生成的sql语句将会是:select from User where name=? and pwd=? and age=?[/color][color=red]
这里将age默认作为了查询条件,修改方法是将age类型换成Integer[/color]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章