ok, so i wrote a query and it returns the correct # of rows...so i think things seem to be working correctly.
i have something like this
Code:
from A a left join fetch ... left join fetch ... left join fetch ... where ...
so right now when i use Query.list(), hibernate returns a list of A objects.
However, what I really need is the corresponding fields in table C. How do I retrieve it?
clam61 wrote:
actually...looking at my own situation, it's not a many to many relationship. i have two one to many associations based on foreign keys
Code:
create table A( aId bigint not null primary key )
create table B( bId bigint not null primary key, AId bigint not null )
create table C( cId bigint not null primary key, BId bigint not null, otherField bigint not null )
i have set up my associations a unidirectional one-to-many association on a foreign key from tables A to B and B to C. I have Set in A which is a collection of B objects and a Set in B which is a collection of C objects
What I would like to accomplish in HQL is this:
Code:
select c.*
from A a,B b,C c
where a.aId = 1 and
a.aId = b.aId and
b.bId = c.bId and
c.otherField = 2
I tried lots of different queries using join fetch but I'm not able to succeed.
[/code]