Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3432620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:28:18+00:00 2026-05-18T07:28:18+00:00

In a simple ‘vote up / vote down’ scenario , I want to sum

  • 0

In a simple ‘vote up / vote down’ scenario , I want to sum the total ‘up’ count .

criteria.add(Restrictions.eq("vote" , Boolean.TRUE));
criteria.setProjection(Projections.rowCount());

The generated SQL is sum(this_.vote) as y1_ and generates correct sum value , but hibernate parsed it as ‘boolean’ value , all become ‘true’ …

How to solve it ? ( if I don’t need to change the ‘vote’ from boolean to integer )

environment : hibernate-3.6.0 , jpa2

Thanks a lot !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:28:19+00:00Added an answer on May 18, 2026 at 7:28 am

    What DB are you using? I think you might need to change the dialect with which hibernate is working.

    Let hibernate use Tinyint for boolean variables.

    Not on my working copmuter atm – sorry. If this might be the right direction get back at me and I will get an example later.

    This might help you get started in the meantime: https://forum.hibernate.org/viewtopic.php?f=1&t=1008105

    cheers

    EDIT:

    Ok. Since you’re using Mysql, you might want to extend an existing MySQL Dialect – e.g. standard MySQL5Dialect:

     public class MySQL5DialectBooleanAsTinyint extends MySQL5Dialect {
    
      public MySQL5DialectBooleanAsTinyint() {
        super();
        registerColumnType(Types.BIT, "tinyint(1)");
      }
    
    }
    

    And that’s it. To use your Custom Dialect, change your hibernate.cfg accordingly:

     <property name="hibernate.dialect">your.package.structure.dao.MySQL5DialectBooleanAsTinyint</property> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have
Simple question, hopefully an easy way and just want to verify I'm doing it
Simple aspx page (ValidateRequest=false) I want the label to write: 2<B //no spaces I've
Simple problem: an existing project allows me to add additional fields (with additional checks
simple question. I want to be able to run my executable with a program
Simple example of scenario I am trying to implement class ATest { int a;
Simple question, but I didn't know what's the keywords to Google. Suppose we want
Simple as the title states: Can you use only Java commands to take a
Simple question, but one that I've been curious about...is there a functional difference between
Simple question, how do you list the primary key of a table with T-SQL?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.