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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:45:55+00:00 2026-06-05T11:45:55+00:00

I have an an entity containing two optional to-many relationships (childA <<-> parent <->>

  • 0

I have an an entity containing two optional to-many relationships (childA <<-> parent <->> childB). Each of these two child entities contain an optional string that I am interested in querying on.

Using the same format, I get the results I expect for one, but not the other. I understand that means I don’t understand the tools I’m working with; and hoped for some insight. This is what the two queries look like:

childA.@count != 0 AND (0 == SUBQUERY(childA, $a, $a.string != NIL).@count)
childB.@count != 0 AND (0 == SUBQUERY(childB, $a, $a.string != NIL).@count)

I would expect to get back results from non-nil instances of both childA and childB only if each entity instances’ string is also nil. My question is, why would one give the results that I expect; while the other does not?

Clarification:
I’m trying to solve the general problem where I’m searching for one of two things. I’m either searching for a default value in an attribute. When the attribute is optional, I’m additionally searching for a nil attribute. The problem is further compounded when optional relationships’ should only be considered when the are populated. Without the relationship count != 0, I get back all parents with a nil relationship. In one case, this is the desired behavior. In another case, this appears to diminish the returned parent count (to 0 results).

For the optional attribute case, the query might look like:

parent.@count != 0 AND (parent.gender == -1) OR (parent.gender == NIL)

Where there are optional relationships in the key-paths, the query takes the form exemplified in the first example.

Again, I have gotten the results I have expected with all but one case, where there doesn’t seem to be anything unique to it’s relationships nor attribute characteristics. Or I should say, there’s nothing unique about this exception in data model structure or query format…

  • 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-05T11:45:56+00:00Added an answer on June 5, 2026 at 11:45 am

    I understand the problem now.
    In my case, it’s usually logical correct to first filter out NSSets with 0 count. But, in the problematic case, it’s logically correct to return the results of both NSSets with 0 count, and NSSets with > 0 count where the attribute is nil (when optional), or the attribute is set to its default value. In other words, in the problematic case, the left condition needs to be removed, resulting in the following format:

    (0 == SUBQUERY(childA, $a, $a.string != NIL).@count)
    

    It seems I’ll need to have the managed objects indicate which scenario is appropriate on a case by case basis…yuk!

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

Sidebar

Related Questions

I have an Entity Framework 4 model, with 2 entities containing many-to-many relationship, so
I have two tables, entities and components, each with a name and unique ID.
I have two Doctrine entities that have a one-to-many relationship, like this: License class
I have a pretty simple console project with an entity model (containing two simple
I'm getting a list of 'team' entities where each 'team' entity has two foreign
I have a collection of entities, which represents a tree. Each entity has a
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want
I have entity e.g. Product which aggregates other entities such as Category . Those
I used JPA and mysql. Each table have entity class.I have four tables. Table1
i have an entity Entity1 that have one to many relation with Entity2 as

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.