调试如下:
1、load()
运行错误如下:
2、get()
运行结果如下:
用get()方法没有找到对象的时候返回null,而没有报强制类型转换错误是因为如下写法是允许的:
1、load()
log.debug("------------------");;
ProductDictate dictate = (ProductDictate);session.load(ProductDictate.class, new Long(100););;
log.debug("+++++++++++"+dictate);;
运行错误如下:
[debug] :--------------------
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 44, of class: com.norteksoft.thiebaut.worksheet.model.ProductDictate
at net.sf.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:24);
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1921);
2、get()
log.debug("------------------");;
ProductDictate dictate = (ProductDictate);session.get(ProductDictate.class, new Long(100););;
log.debug("+++++++++++"+dictate);;
运行结果如下:
[debug] :------------------
[debug] :+++++++++++null
用get()方法没有找到对象的时候返回null,而没有报强制类型转换错误是因为如下写法是允许的:
Object a = (Object); null;