-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How can I control entities fetched via associations?
PostPosted: Thu Dec 20, 2007 10:41 am 
Newbie

Joined: Thu Dec 20, 2007 9:55 am
Posts: 2
I have a pretty basic database model in which I have an entity called Section which has a @OneToMany join with Question. At first, my thought was to make the association eagerly fetched, so that the following HQL query...

Code:
from Section


would give me sections with each sections questions already initialized. This worked fine, but then I realized I really needed a subset of questions for each section. This has proven to be incredibly difficult to achieve. Here's a few things I've tried...

Code:
from Section left join fetch Question with id in (select...)


Or on the relationship...

Code:
@OneToMany
@Where("id in (select...)")
public List<Question> getQuestions()
{
    return questions;
}


Or at the entity definition...

Code:
@Entity
@FilterDef("questionFilter")
@Filter(name="questionFilter", criteria="id in (select...)"


None of that's working for me. I really need my query to return a list of sections, and I really need my sections to have a subset of the available questions they've been joined with. Is there any way to do this?[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.