views:

29

answers:

1

I want to make an hibernate querycount on a table.

I have to values, one string and one boolean

HibernateUtil.queryCount(VoteOnPublication.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

+2  A: 

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});
Pascal Thivent
Thank you that's it, i was totally lost, haven't been practicing java for more than 1 year !
accepted answer with 0 upvotes just looks odd :)
Bozho
@Bozho Thanks!(pad)
Pascal Thivent