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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:28:34+00:00 2026-06-04T15:28:34+00:00

I’d like to use @Where annotation in Hibernate to remove objects which have been

  • 0

I’d like to use @Where annotation in Hibernate to remove objects which have been marked ‘deleted’ by a boolean property on that object. For example the following should prevent any deleted addresses from being loaded by Hibernate:

@OneToMany(mappedBy="contact")
@Where(clause="deleted=FALSE")
private Set<Address> addresses; 

However when I use a clause like deleted=FALSE then Hibernate will mangle the boolean literal by prefixing it with a table name, which causes the query to fail. For example:

select ... from address address0_ where  ( address0_.deleted=address0_.FALSE)  and address0_.contact_id=?

What I expected is something like (address0_.deleted=FALSE) instead of (address0_.deleted=address0_.FALSE).

Is there a way to specify the @Where clause or configure Hibernate to correctly output the boolean value?


PS. Note that it is possible with some databases to specify the boolean value as a string literal like this:

@Where(clause="deleted='FALSE'")

That will get converted to (address0_.deleted='FALSE') which works just fine in, for example, PostgreSQL. However I am using HSQLDB for this project, and HSQLDB does not seem to support boolean string literals. On HSQL I get the following exception when using deleted='FALSE':

org.hsqldb.HsqlException: data exception: invalid character value for cast

  • 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-06-04T15:28:35+00:00Added an answer on June 4, 2026 at 3:28 pm

    I’ve discovered bug reports about this which have been unresolved for more than six years! The Hibernate issue tracker has HHH-1587, HHH-2775 and ANN-647 on the problem.

    The solution is to create a custom Dialect class which registers true, false and unknown as keywords (these are the official boolean literals in the SQL spec). This causes Hibernate to recognise them as keywords and thus stop prefixing them as if they were columns.

    Here’s my custom Dialect class which solved the problem for me:

    public class ImprovedHSQLDialect extends HSQLDialect {
    
        public ImprovedHSQLDialect() {
            super();
            registerKeyword("true");
            registerKeyword("false");
            registerKeyword("unknown");
        }
    }
    

    Once this dialect is in use, @Where(clause="deleted=FALSE") works correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have some data like this: 1 2 3 4 5 9 2 6
I used javascript for loading a picture on my website depending on which small

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.