Hey,
following problem( with a cache strategy for all classes and collections):
We have two tables mapped to classes PropertyGroupHibData and PropertyHibData.
PropertyGroupHibData has a collection to PropertyHibData( Resolves a 1-N Relation).
Code:
<hibernate-mapping>
<class
name="PropertyGroupHibData"
table="PropertyGroups">
<id
name="propertyGroupID"
type="long">
<generator class="native"/>
</id>
<set name="properties" inverse="true" >
<key column="propertyGroupID"/>
<one-to-many class="PropertyHibData"/>
</set>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class
name="PropertyHibData"
table="Properties">
<id
name="propertyID"
type="long">
<generator class="native"/>
</id>
<many-to-one name="propertyGroup" column="propertyGroupID"
class="PropertyGroupHibData"
/>
</class>
</hibernate-mapping>
When I now query a element of PropertyGroup, than delete a Property from this PropertyGroup and afterwards query the PropertyGroup again I get the following exception:
Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [PropertyHibData#34]
We used to resolve this by removing the PropertyHibData from all collections it could be contained in. But I now have the question if there is no better way of resolving this problem?
I thought of handling this by manipulating the cache, but this doesn't seem to be the optimal solution. Altough it would bewilder me if Hibernate wouldn't jave a solution to this Problem.
Thanks for your help,
ZeroOneInfinity