Replies: 2 comments 1 reply
-
One way you could do this is by looking for the "root C" i.e. with recursive parent_hierarchy(c_id, b_id, a_id) as (
select c.id, c.b.id, c.b.a.id
from C c where relationToC is null
union all
select c.id, h.b_id, h.a_id
from C c
join parent_hierarchy h on h.c_id=relationToC.id
)
select * from parent_hierarchy |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for reply - but how having c.id from the bottom of the hierarchy use it? And how to map it into hibernate/blaze code? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
I have situation where my objects are stored in a parent-child relation, but pointer to the parent is not stored in the object itself but in the collection
The object look like this:
@entity
`class A { // root of hierarchy
@id
long id;
}
@entity
class B {
private RelationToA A
}
@entity
class C {
private RelationToB relationToB;
private RelationToC relationToC;
}
`
RelationToA and RelationToC are intermediate classes with value of related object's identifier.
Class A can have many B and B might have many C. C can have one parent C. So it might look like A -> B -> C1 -> C2 -> C3 -> C4
The problem is when doing some query based on some criteria I have collection of C objects returned but during the query execution I have to check some property of the root of whole hierarchy - the A object. So my query looks like:
`
`
How to do that in Blaze? I have all the criterias for my main query for selecting Cs, but when I need to get my A root I am confused.
Ideally would be to have the query I pasted mapped as an entity and do join but there's parameter in the query for a C object.
What parts of the Blaze framework should I use to achieve what I want?
Beta Was this translation helpful? Give feedback.
All reactions