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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:33:06+00:00 2026-05-23T12:33:06+00:00

I am having an issue with creating queries with javax.persistence.criteria.CriteriaBuilder. I am using EclipseLink

  • 0

I am having an issue with creating queries with javax.persistence.criteria.CriteriaBuilder. I am using EclipseLink 2.1 and an Oracle 10g database. When building a query with multiple restrictions it will use only the first restriction, not both of them.

Here is my code:

CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Assignment> query = cb.createQuery(Assignment.class);
Root<Assignment> assignment = query.from(Assignment.class);

query.where(
    cb.equal(assignment.get("request"), request),
    cb.isNull(assignment.get("endDate")));

return getEm().createQuery(query).getResultList();

The query producted is:

SELECT ASSX_ID, END_DATE, BEGIN_DATE, COMMENTS, 
       ASSX_OER_ASSIGNED_TO_ID, OER_OER_ID_ASSIGNED_BY, 
       ASSX_RQST_ID 
FROM TARTS.ASSIGNMENT_XREF 
WHERE (ASSX_RQST_ID = ?)

It looks good except for the where clause. I am expecting:

SELECT ASSX_ID, END_DATE, BEGIN_DATE, COMMENTS, 
       ASSX_OER_ASSIGNED_TO_ID, OER_OER_ID_ASSIGNED_BY, 
       ASSX_RQST_ID FROM TARTS.ASSIGNMENT_XREF 
WHERE (ASSX_RQST_ID = ? AND BEGIN_DATE IS NOT NULL)

It doesn’t matter if I use cb.and(arg1, arg2) or not also. Am I doing something wrong? Any help will be appreciated.

  • 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-23T12:33:07+00:00Added an answer on May 23, 2026 at 12:33 pm

    Your query looks perfectly ok. As you’ve mentioned, CriteriaQuery.where(Predicate... restrictions) already uses the conjunction of the predicates so there’s no need to use cb.and().

    The only things I could imagine:

    • bug in EclipseLink (try the same with Hibernate)
    • some sort of optimization, maybe endDate may never be null?
    • your getEm() method does some strange things
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having an issue with creating a query in oracle which doesnt seem to
I am creating a modal window using jquery. I am having an issue with
I'm having an issue creating my Oracle DB with schemaexport function of NHibernate. For
I'm having an issue creating a link like <a href=javascript:window.open('www.microsoft.com');>Visit Microsoft</a> using stringbuilder. I
I am having an issue with creating a splice for a weighted index. I
I am creating a personnel recruitment website and am having an issue with adding
I'm having the following issue with my hibernate 3.6.10 project: org.springframework.beans.factory.BeanCreationException: Error creating bean
Hi guys I am having issue I have this query: SELECT * FROM useraccount
I am having an issue with creating and adding sales/quote_address objects to the multishipping
I'm having an issue with an creating application shortcut on the desktop from a

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.