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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:38:29+00:00 2026-06-15T13:38:29+00:00

I have an entity A, and an entity B. The entity B is and

  • 0

I have an entity A, and an entity B.
The entity B is and three. And the entity A is always link with just one entity B.

Below represents this relationship as a tree:

A1
+-B1
 +-B2
 +-B3
 | +-B4
 |
 +-B5
 +-B6
   +-B7
     +-B8

And here is the data as it is stored on the database to represent the Entity B:

#    parent_id    entity_a_id    name
1    null         1              B1
2    1            1              B2
3    1            1              B3
4    3            1              B4
5    1            1              B5
6    1            1              B6
7    6            1              B7
8    7            1              B8

I want to map on the entity A to bring the root entity B, it means that I want to bring the entity B where entity_a_id is the same as the current (probably mappedBy) and the parent_id is null.
Until now I didn’t found how to add a custom query to a relationship (parent_id is null). Is it possible?

  • 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-15T13:38:30+00:00Added an answer on June 15, 2026 at 1:38 pm

    If I understand the requirement correctly, you want to restrict the relationship field to contain only certain entities based on criteria. In this case you might find Hibernate filters useful.

    EDIT: Hibernate also features the @Where annotation for conditional joins, Take a look at This simple example

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

Sidebar

Related Questions

I have an ADO .Net Entity Data Model for my database. In this Model
I have three Entity Objects. The relationship between these entities is kinda love triangle!
I have an issue in entity framework code first, three table in database as
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I ran across this code in one of our Entity Framework applications. I know
I have a simple entity class that has a Date property. This property corresponds
I have a simple Entity data model (using VS2010) that I reverse engineered from
I'm using Entity Framework 4.1 Code First. In my entity, I have three date/time
This is something i just can't figure out working with Core Data. I want
I have an entity class that represents a person and an enum that represents

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.