开发者

Hibernate querycount query, dont know how to do

I want to make an hibernate querycount on a table.

I have to values, one string and one boolean

HibernateUtil.queryCount(V开发者_如何学PythonoteOnPublication.class, new String[] {VOTED_PUBLICATION_ID_FIELD, FOR_OR_AGAINST_FIELD}, **********************);

my voted_publication_id_field is a string, and my for or against field is a boolean.

What should i put in my second part of the query ? I first put : new String[] {publication.getId(),true.toString() but that didnt work. i think the new String is the mistake but i dont know what to put


This is a wild guess (because HibernateUtil is a custom class, it's not part of Hibernate API) but I'd bet on the following signature for the queryCount method:

public static int queryCount(Class<?> clazz,
                             String[] properties,
                             Object[] values) {
    ...
}

So try this:

HibernateUtil.queryCount(VoteOnPublication.class, 
                         new String[] {VOTED_PUBLICATION_ID_FIELD, FOR_OR_AGAINST_FIELD},
                         new Object[] {publication.getId(), true});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜