日期:2014-05-17  浏览次数:20713 次

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);这样难道也有问题

你的报错信息肯定还有别的东西,贴出来看看