方法如下:
复制内容到剪贴板 程序代码
public List getPtsByCateID(CategoryVO cate)
{
Transaction tx = null;
List list =null;
Session session = HibernateUtil.getSession();
try {
tx = session.beginTransaction();
list =session.find("from ProductVO as p where p.cate="+cate.getId()+"");
{
Transaction tx = null;
List list =null;
Session session = HibernateUtil.getSession();
try {
tx = session.beginTransaction();
list =session.find("from ProductVO as p where p.cate="+cate.getId()+"");
今天做商城购物的时候,再原有表基础上加了一个double类型的字段,抛出了这个异常:
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of...
原因:查询结果中包含null的项 对于一些数字项包含null,定义该项时必须使用wrapper类型,而不能是primitive类型,例如使用Integer等,而不能是int否则会抛出exception!
解决:映射为int,double的字段,在建表时,某些int或者double字段的default 0,导致exception setting property value with CGLIB setter 这些字段出错.这些字段最后都有默认值.设置好默认值问题就可以解决了。
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of...
原因:查询结果中包含null的项 对于一些数字项包含null,定义该项时必须使用wrapper类型,而不能是primitive类型,例如使用Integer等,而不能是int否则会抛出exception!
解决:映射为int,double的字段,在建表时,某些int或者double字段的default 0,导致exception setting property value with CGLIB setter 这些字段出错.这些字段最后都有默认值.设置好默认值问题就可以解决了。
argument type mismatch异常:
这表明有部分属性的数据类型不匹配,比如下列情况
当我们有一个HIBERNATE实体,并且在表单提交到ACTION后,并不想强转为 ACTIONFORM,而是想将 FORM直接转成HIBERNATE实体如下:
原本情况: UserForm userForm=(UserForm)form;
现情况: User user=(User)form;或你有BEANUTIL这个工具的写法是User user=BeanUtils.copyProperties(new User(), form);
这表明有部分属性的数据类型不匹配,比如下列情况
当我们有一个HIBERNATE实体,并且在表单提交到ACTION后,并不想强转为 ACTIONFORM,而是想将 FORM直接转成HIBERNATE实体如下:
原本情况: UserForm userForm=(UserForm)form;
现情况: User user=(User)form;或你有BEANUTIL这个工具的写法是User user=BeanUtils.copyProperties(new User(), form);
Tags: 异常
郁闷了好久,终于在goole上找到了错误原因
ObjectNotFoundException: No row with the given identifier exists
Where it can occur:
This might occur if you try to load a non-proxied object with session.load() or you load a proxied object and later access the proxy. It may also occur when loading mapped collections which are not eagerly fetched.
What it means:
This means just what it says - Hibernate expected to have a row with a certain id in the database, and did however not find it.
How it can be caused:
ObjectNotFoundException: No row with the given identifier exists
Where it can occur:
This might occur if you try to load a non-proxied object with session.load() or you load a proxied object and later access the proxy. It may also occur when loading mapped collections which are not eagerly fetched.
What it means:
This means just what it says - Hibernate expected to have a row with a certain id in the database, and did however not find it.
How it can be caused:
<script>
var online= new Array();
</script>
<script src="http://webpresence.qq.com/getonline?Type=1&13137813:"></script>
<script>
if (online[0]==0)
document.write(" <img src=qq/QQoffline.gif border=0 align=middle><a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=qq号码&Site=在线咨询&Menu=no' title='客服不在线,请留言'>qq号码</a>");
else
document.write(" <img src=qq/QQonline.gif border=0 align=middle><a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=qq号码&Site=在线咨询&Menu=no' title='在线即时交谈'>qq号码</a>");
var online= new Array();
</script>
<script src="http://webpresence.qq.com/getonline?Type=1&13137813:"></script>
<script>
if (online[0]==0)
document.write(" <img src=qq/QQoffline.gif border=0 align=middle><a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=qq号码&Site=在线咨询&Menu=no' title='客服不在线,请留言'>qq号码</a>");
else
document.write(" <img src=qq/QQonline.gif border=0 align=middle><a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=qq号码&Site=在线咨询&Menu=no' title='在线即时交谈'>qq号码</a>");