User user = session.load(id,User.class);
当load获取不到数据时,不返回NULL,返回一个该对象的代理,代理内获取不到数据会抛异常。具体如下;
User$Proxy extends User{
private int id = id;
User realUser = null;
getName(){
if(realName == null){
realName = session.get(id);
if(realName == null){
throw execption;
}
}
return realName.getName();
}
}
User user = session.get(id,User.class);
当get获取不到数据时,返回NULL