hibernate 中的session.createQuery(hql) 把hql中的类名改变了,导致异常错误,谁帮忙看看?
代码:Sessionsession=sessionFactory.openSession();Stringhql="selectcord.versionfrom"+Car...
代码:
Session session=sessionFactory.openSession();
String hql="select cord.version from "+CartCord.class.getName()+" as cord where cord.productID=:pID and cord.userID=uid";
Query query=session.createQuery(hql);
query.setParameter("pID",productID);
query.setParameter("uid",userID);
List list=query.list();
调试到createQuery时:hql=select cord.version from data.entities.CartCord as cord where cord.productID=:pID and cord.userID=uid
执行createQuery时报错:org.hibernate.QueryException: could not resolve property: userID of: data.entities.ProductInfo [select cord.version from data.entities.ProductInfo as cord where cord.productID=:pID and cord.userID=uid]
这把我要查询的类名换了,然后报错了,求问这个怎么解决?很奇葩啊!
我没有财富了,求大家帮帮看看。 展开
Session session=sessionFactory.openSession();
String hql="select cord.version from "+CartCord.class.getName()+" as cord where cord.productID=:pID and cord.userID=uid";
Query query=session.createQuery(hql);
query.setParameter("pID",productID);
query.setParameter("uid",userID);
List list=query.list();
调试到createQuery时:hql=select cord.version from data.entities.CartCord as cord where cord.productID=:pID and cord.userID=uid
执行createQuery时报错:org.hibernate.QueryException: could not resolve property: userID of: data.entities.ProductInfo [select cord.version from data.entities.ProductInfo as cord where cord.productID=:pID and cord.userID=uid]
这把我要查询的类名换了,然后报错了,求问这个怎么解决?很奇葩啊!
我没有财富了,求大家帮帮看看。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询