org.hibernate.QueryException could not resolve property userid of com.xxx.yyy.Pay
使用到外键userid的时候,必须使用userinfo.userid方法才能得到。
=========================================
javax.naming.NameNotFoundException Name hibernate_connection_factory is not bound in this Context
原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。
例如many-to-one设置了以后,仍然在其中设置相冲突的property属性。
使用到外键userid的时候,必须使用userinfo.userid方法才能得到。
=========================================
javax.naming.NameNotFoundException Name hibernate_connection_factory is not bound in this Context
原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。
例如many-to-one设置了以后,仍然在其中设置相冲突的property属性。
Tags: Exception
竟然弄了好几个小时,查错。。。服了
先把错误的列出来:
先把错误的列出来:
复制内容到剪贴板 程序代码
public String countChoose(String name, String cid, String state) { //选择算法
int lable = 0; //跟踪标记
String sqladd = ""; //动态生成的sql部分语句
String sql = "";
if (!name.equals("")) {
sqladd = "p.name='" + name + "'";//这里也需要注意,单引号
int lable = 0; //跟踪标记
String sqladd = ""; //动态生成的sql部分语句
String sql = "";
if (!name.equals("")) {
sqladd = "p.name='" + name + "'";//这里也需要注意,单引号
方法如下:
复制内容到剪贴板 程序代码
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 这些字段出错.这些字段最后都有默认值.设置好默认值问题就可以解决了。
郁闷了好久,终于在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: