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]