2 qq 28573739 qq_28573739 于 2016.03.21 09:52 提问

hql查询报错。。。。实体类问题
hql

hql语句:
String hql="from CouponPublishEntity e inner join e.couponpool c where c.owner='"+userId+"' and e.pubid in ("+ids+") ";
报错
[org.jeecgframework.core.common.exception.GlobalExceptionResolver]全局处理异常捕获:
org.hibernate.QueryException: could not resolve property: couponpool of: com.sendiy.hh.coupons.entity.CouponPublishEntity [from com.sendiy.hh.coupons.entity.CouponPublishEntity e inner join e.couponpool c where c.owner='4028668150c6aedb0150c6ddde750005' and e.pubid in ('2') ]
问题是实体类写错了吗,还是语法错了·

3个回答

zhangsiqiong
zhangsiqiong   2016.03.21 10:15
已采纳

实体类中没有找到couponpool,看是不是你实体类中不是这样写的, hql区分大小写

zhangsiqiong
zhangsiqiong 如果你两张实体有关系 你试试String hql="from CouponPublishEntity e,CouponPublishEntity c where c.owner='"+userId+"' and e.pubid in ("+ids+") ";
一年多之前 回复
qq_28573739
qq_28573739 实体类:@Entity @Table(name = "couponpool", schema = "") @SuppressWarnings("serial") public class CouponPoolEntity implements java.io.Serializable { /**couponseqid*/ private java.lang.Integer couponSeqId; /**批次号*/ private java.lang.String pubId; /**序号*/ private java.lang.String couponNo; private java.lang.String serialno; 把couponpll改成CouponPoolEntity也不好使
一年多之前 回复
zhangsiqiong
zhangsiqiong   2016.03.21 13:08

CouponPublishEntity这个实体和CouponPoolEntity这个实体不是两个实体吗,那你怎么从CouponPublishEntity 中拿到CouponPoolEntity

String hql="from CouponPublishEntity e inner join CouponPoolEntity c where c.owner='"+userId+"' and e.pubid in ("+ids+") ";

zhangsiqiong
zhangsiqiong   2016.03.21 13:09

CouponPublishEntity这个实体和CouponPoolEntity这个实体不是两个实体吗,那你怎么从CouponPublishEntity 中拿到CouponPoolEntity

String hql="from CouponPublishEntity e inner join CouponPoolEntity c where c.owner='"+userId+"' and e.pubid in ("+ids+") ";

qq_28573739
qq_28573739 回复有_道_是: 报错啊。。不对啊!
一年多之前 回复
qq_28573739
qq_28573739 改成String hql="from CouponPublishEntity e inner join CouponPoolEntity c where c.owner='"+userId+"' and e.pubid in ("+ids+") ";了 又报Path expected for join! at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:369)。。
一年多之前 回复
enpterexpress
enpterexpress 大侠好厉害(。)(。)
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!