You can use join fetching or batch reading for this, either at the query level, or the mapping level.
For mapping level, you can use the EclipseLink @JoinFetch annotation or xml to always join the relationship from Courses to Course. You could also use a DescriptorCustomizer to set enable batch reading on the OneToOneMapping for course.
Joe Mc. wrote:
Hi,
I am playing with additional columns in join tables.
The following example:
Customer visits some Courses
This n-m-Relation contains additional attributes in the n-m-table (join table), for example: note, year etc.
One solution is to use @OneToMany and @ManyToOne with a concret join table in Java, insteed of @ManyToMany.
In this Association class, is it possible to hold the additional columns
This solution is fine and worked.
In @ManyToMany is it possible to tell EclipseLink, that he use only ONE Select statement, to get all the data from the different tables (with outer joins etc.).
Is it possible to do this now with the OneToMany and ManyToOne?
At the moment I get a join of Customer and Courses. And EclipseLink fires for every Course, the customer holds, an additional SQL SELECT statement to get the data :-(
I general: I want the same SQL SELECT statement as in the ManyToMany case. Is it possible?
Thanks for any advice!
Regards
M.Joe