这样写的时候返回的值是0
public long getTopicInfoCount(String topicId) {
long count = 0;
count = (Long) getHibernateTemplate().find(
"select count(*) from NewsTopicDoc where topicid = ?",topicId).get(0);
return count;
}
这样写返回的是正确的值(非0),而且传的值是相同的,希望能给解答一下
public long getTopicInfoCount(String topicId) {
long count = 0;
count = (Long) getHibernateTemplate().find(
"select count(*) from NewsTopicDoc where topicid = '20150116-74'").get(0);
return count;
}
------解决思路----------------------
。。。第二段代码,topicid 直接写死,没用传入的值,传参只是个摆设吧
不了解Hibernate
你看看topicid = ?这里,?两边是否要加上单引号
------解决思路----------------------
topicid = '20150116-74' =号后面应该为一个变量吧,
如果是常量,肯定值是相同的,因为查询语句都一样。
------解决思路----------------------
看下传入的 topicid 是否前后有空格之类的