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

  • Home
  • SEARCH
  • 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 7825311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:55:41+00:00 2026-06-02T08:55:41+00:00

I want to perform a SELECT with several conditions, using Ibator’s generated Example classes.

  • 0

I want to perform a SELECT with several conditions, using Ibator’s generated Example classes.

As described here in the usage notes, it’s fairly easy to use criteria.andFieldIsSomething() and example.or(example) to compose a WHERE clause with multiple OR and AND operators.

I could just write this:

example.createCriteria().andIntegerIsEqualTo(int).andDateIsEqualTo(someday);
example.or(example.createCriteria().andIntegerIsNull().andDateIsEqualTo(someday));
example.or(example.createCriteria().andIntegerIsEqualTo(int).andDateIsNull());
example.or(example.createCriteria().andIntegerIsNull().andDateIsNull());

But first, it’s kind of tedious and redundant, and it would output the following code:

SELECT * FROM zeTable
WHERE (integer = int AND date = someday)
OR (integer IS NULL AND date = someday)
OR (integer = int AND date IS NULL)
OR (integer IS NULL AND date IS NULL);

A more elegant (and probably efficient) way of writing that would be:

SELECT * FROM zeTable
WHERE (integer IS NULL OR integer = int)
AND (date IS NULL OR date = someday);

The test for NULL prevents me from using the .andFieldSomethingIn(List values) method efficiently, and while I kept this example simple, the code I have to write implies crossing 5 or 6 fields like that, which could amount to 36 different Criteria.

This seems ridiculous to me, so I assume there must be a better way. Can someone suggest something ?

  • 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-02T08:55:43+00:00Added an answer on June 2, 2026 at 8:55 am

    Tl;dr: is it not possible. Deal with it.

    I spend some time investigating this, and this question was posted here for over a month. It seems there is no way to this with Ibator’s Criteria and Example classes.

    My guess is, it’s not meant for that.
    Workaround: if you want complex clauses and effciency, write your own logic in the SQL_MAP.

    It’s what I ended up doing. If anyone else can offer a better answer later, I’ll accept it.

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

Sidebar

Related Questions

I want to perform a LIKE style comparison with an IN operator e.g.: select
I want to perform a simple query like this in my PHP, SELECT noslots
I want to perform a 'SELECT' statement with a byte array (binary) parameter as
I want to perform a JOIN on two Datatables in a Dataset. For example,
I want to perform a select which returns a few columns of data, and
I want to store 50000 or more strings and I need to perform several
I have to perform a SELECT operation in the DB. Since I want to
I want to perform a conditional right join in this SQL SELECT * FROM
In Oracle, given a list of table names, I want to perform 'select column1
I want to perform a cartesian product between two SELECT statements as SELECT 1,

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.