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 7402687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:48:18+00:00 2026-05-29T04:48:18+00:00

While database design I used a field name deleted and use it as Boolean.

  • 0

While database design I used a field name deleted and use it as Boolean. Everything seems fine.

I’m using hibernate 3.6.9. So I’ve configured applicationContext

prop key=”hibernate.query.substitutions”>true=1 false=0

In my sessionFactory bean. So when Im saving my object, it converting my Boolean as 1/0.
So but problem is when Im retrieving object from database, Im getting

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean

Can any of you tell how to solve this problem?

  • 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-29T04:48:19+00:00Added an answer on May 29, 2026 at 4:48 am

    I would guess that hibernate.query.substitutions only work for queries, but not for entities.

    What I would try is to implement a Custom User Type that maps a boolean to 1 or 0. And than use that custom user type to annotate the boolean field of my entity.

    @org.hibernate.annotations.Typ(type="com.example.Boolean01Type")
    private boolean deletes; 
    

    Have a look at this blog for an example how to implement a custom type. (I am not 100% sure, but I remember that there was somehow two concepts of custom types in hibernate, one more powerful than the other)

    But definitely have a look at the standard custom type “yes_no”, that is really close to the one you need to write.

     @org.hibernate.annotations.Type(type="yes_no")
     boolean myBoolean;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following exception while adding data into database: org.hibernate.HibernateException: The database
Quick backstory...I have some training in database design and administration. I have used them
Its been a while since my Database Design classes in my sophomore year at
Can source code examples be kept in a SQL database while retaining all formatting
While opening any MS Access database, a security warning appears saying that the file
While trying to connect to a database that's set to read only, the connection
A while ago, I set up my company's local (non-internet) client database on my
I've encountered this problem (while trying to add SQL Server Database (.mdf) file to
A while ago, I wrote a program that outputs any localhost or network database
I'm so surprise while I'm working in Fluent NHibernate. I got my legacy database

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.