I am almost giving up and decided to hit the forums hoping to find an answer or at least a direction...
It seems not possible to get a 1-1 bidirectional relationship between two tables (left and right) using a join fetch strategy.
First of all, no I cant use lazy loading because I need to load an inmemory, disconnected cache from the db and lazy fetching wont work.
My main problem is that I have thousands of rows and the N+1 problem is killing me. Last time loading all the data took more than 40 mins with N selects after the initial one.
So I tried to change the fetching strategy to join left and right the problem persists, i.e. N+1. It seems that Hibernate correctly identifies both right and left entity from the join resultset row, but issues another select when resolving the property from right to left.
At this point I have a <many-to-one> on the left table and a <one-to-one> on the right table using property-ref.
My first question is: is this scenario (joined bidirectional 1-1) even supported in Hibernate? What am I doing wrong? Or are there alternatives to speed up the loading?
thanks!
|