当前位置: 代码迷 >> Java Web开发 >> HQL不识别占位符,抛出反射错误
  详细解决方案

HQL不识别占位符,抛出反射错误

热度:206   发布时间:2016-04-12 22:07:00.0
HQL不识别占位符,抛出反射异常
代码如下
Query query=this.getSession(true).createQuery("select count(c) from Comment c where c.article_id= :articleId");
     System.out.println("test0");
     query.setParameter("articleId", articleId);
     System.out.println("test1");
抛出java.lang.reflect.InvocationTargetException异常System.out.println("test0");没有执行。
而将占位符改为固定数字则正常
hql ssh 异常

------解决方案--------------------
this.getSession(true).createQuery("select count(c) from Comment c where c.article_id="+article_id);这样难道也有问题

你的报错信息肯定还有别的东西,贴出来看看
  相关解决方案