Hibernate version: 3.1.3
Hello, I have a one-to-many relation (bag) mapped like:
Code:
<class name="AAA">
<bag name="proposals" inverse="true" cascade="lock" fetch="join">
<key column="aaa_id" />
<one-to-many class="BBB"/>
</bag>
...
I get some AAA:
Code:
session.get(AAA.class, id)
this generates a join between AAA and BBB, as specified (fetch="join").
However when I do
Code:
session.get(AAA,class, id, LockMode.UPGRADE)
what I want is a query like:
Code:
select ... from aaa a left join bbb b on aaa.id=bbb.aaa_id where a.id=id for update
Instead, hibernate no longer generates a join, and thus locks only AAA. I think this is strange, since I have specified cascade="lock" so I want and would expect to get a lock on the related BBB instances as well.
I think this is a bug. I experimented with various cascade settings, fetch, lazy etc etc, but there seems to be no way whatsoever to convince Hibernate to execute a select ... for update statement over more than 1 single table.
Is there a solution or should I file a bug?
TIA, Peter Mutsaers