Problem remains in 3.3.1.GA
Debbuging Hibernate's code I found that the AbstractEntityPersister tries to use an "static key loader" from the map "uniqueKeyLoaders" which is always empty, hence -> NPE (line 1681)
There is some logic in the "getAppropriateUniqueKeyLoader" and we can make it not to create it's own "uniqueKeyLoader" and avoid NPE.
The result ends being a clean workaround and worked for the webapp we are building.
For some reason, if there is a filter enabled in the session, it will not use the "static key loader" and will create one. For that reason, I created a dummy Filter and enabled it. The filter does nothing, it's just there to make an "if condition" false.
the hbm for the parent must have the filter for the many-to-many relation like this:
Code:
<map name="positionDetailDatesMap" table="so_owner.op_voyage_positions" mutable="false" inverse="true" >
<key>
<column name="company_id"></column>
<column name="ship_id"></column>
<column name="voyage_no"></column>
</key>
<map-key type="long" formula="key_position"></map-key>
<many-to-many class="com.osg.chops.shipboard.domain.PositionDetailsDates" property-ref="keyPosition" order-by="arr_datetime asc" not-found="ignore">
<formula>key_position</formula>
</many-to-many>
<filter name="myFilter" condition="1=1"></filter>
</map>
Also, in the same file, somewhere at the end declare the filter
Code:
<filter-def name="myFilter">
</filter-def>
The final blow to it is to enable the filter for the current session.
Code:
currentSession.enableFilter("myFilter");
In my case I have a request filter and we use one session per request, so I make sure to run thi code on every request.
I'd love to know what the problem may be. This is just a workaround and Im not sure in deep how this affect hibernate behavior, performance, etc.
Can someone please bring more light on this?
bye bye
Dj