Hi,
I'm using GlassFish V2 and am trying to run a JPQL query, but am having
the n+1 problem where it should be running a single query, but it is
running a query for every single result. The JOIN FETCH feature is
supposed to fix that, and it does in a way. The generated SQL changes
to include all fields from both tables to make it possible to build all
entities using a single query. The problem is that this query is still
being run for every single result.
I have two entities: Hotel and HotelSettings. Both entities have an
id field called hotelCode which happen to have the same value in both
tables. Hotel has the following relationship:
@OneToOne
@JoinColumn(name="SiteCode", insertable=false, updatable=false)
private HotelSettings settings;
The HotelSettings entity doesn't know about the Hotel entity. The JPQL
query looks like this:
SELECT h FROM Hotel h LEFT JOIN FETCH h.settings
Any ideas? Is this a TopLink Essentials bug?
Thanks,
Ryan