There is the @Fetch annoation which might solve your problem.
Thanks, but i couldn't find anything about the @Fetch annotation and how to use it.
It doesn't seem to be part of the ejb specs. Is it a specific Hibernate tag ?
Could you give me a link or a piece of example ?
Sorry, it was late when I made the last post. I was thinking about the Fetch Joins.
22.214.171.124 Fetch Joins
An important use case for LEFT JOIN is in enabling the prefetching of related data items as a side effect
of a query. This is accomplished by specifying the LEFT JOIN as a FETCH JOIN.
A FETCH JOIN enables the fetching of an association as a side effect of the execution of a query. A
FETCH JOIN is specified over an entity and its related entities.
The syntax for a fetch join is
fetch_join ::= [ LEFT [OUTER] | INNER ] JOIN FETCH join_association_path_expression
The association referenced by the right side of the FETCH JOIN clause must be an association that
belongs to an entity that is returned as a result of the query. It is not permitted to specify an identification
variable for the entities referenced by the right side of the FETCH JOIN clause, and hence references
to the implicitly fetched entities cannot appear elsewhere in the query.
The following query returns a set of departments. As a side effect, the associated employees for those
departments are also retrieved, even though they are not part of the explicit query result. The persistent
fields or properties of the employees that are eagerly fetched are fully initialized. The initialization of
the relationship properties of the employees that are retrieved is determined by the metadata for the
Employee entity class.
SELECT d FROM Department d LEFT JOIN FETCH d.employees WHERE d.deptno = 1
A fetch join has the same join semantics as a left outer join, except that the related objects specified on
the right-hand side of the join operation are not returned in the query result or otherwise referenced in
the query. Hence, for example, if department 1 has five employees, the above query returns five references
to the department 1 entity.
Extract from ejb-3_0-pfd-spec-persistence.pdf