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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:50:10+00:00 2026-05-25T11:50:10+00:00

I have two entities: EntityA and EntityB. EntityB has a foreign field of EntityA:

  • 0

I have two entities: EntityA and EntityB. EntityB has a foreign field of EntityA:

@DatabaseField(foreign=true, columnName=ENT_A_NAME)
private EntityA entityA;

Now I want to query all entries of EntityB where EntityA is null. So I’ve made the following query:

bDao.queryBuilder().where().isNull(EntityB.Ent_A_NAME).prepare();

If I execute the query I get an empty result set back.

If I execute queryAll() I see that the entries of EntityB have always an associated Order-Object with all values set to null/0.

How can I execute my query?

  • 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-25T11:50:11+00:00Added an answer on May 25, 2026 at 11:50 am

    I’m not sure @Toni4780. The following test case works for me. I don’t see anything that you are doing wrong.

    In the table for EntityB, ORMLite actually stores the id of the EntityA so I am wondering if it is null or 0. Have you tried the following?

    bDao.queryBuilder().where().eq(EntityB.Ent_A_NAME, 0).prepare();
    

    or both:

    bDao.queryBuilder().where().isNull(EntityB.Ent_A_NAME).
        or().eq(EntityB.Ent_A_NAME, 0).prepare();
    

    Here’s my unit test code that works:

    Dao<Order, Integer> orderDao =
        DaoManager.createDao(connectionSource, Order.class);
    TableUtils.createTable(connectionSource, Order.class);
    int numOrders = 10;
    for (int orderC = 0; orderC < numOrders; orderC++) {
        Order order = new Order();
        order.val = orderC;
        assertEquals(1, orderDao.create(order));
    }
    List<Order> results = orderDao.queryBuilder().where()
        .isNull(Order.ACCOUNT_FIELD_NAME).query();
    assertNotNull(results);
    assertEquals(numOrders, results.size());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two entities, EntityA and EntityB. EntityB can optionally be related to EntityA,
I have two entities: Patient and Job. Patient has a to-many relationship to Job
I have two entities: User and Event. Each user has a list of events
I have two Hibernate entities named Alpha and Beta, and Alpha has a *-to-one
I have two entities event and time. The event entity has a 1 to
i have two entities page and user. the page has a property userId on
I'm getting a list of 'team' entities where each 'team' entity has two foreign
I have two entities, Parent and Child, in Entity Framework. The parent has a
I have two entities User and Event. Each user has a list of events
I have two entities, User and UserSetting. The obvious relationship between these two has

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.