Extra INFO, some sample setup how it is now
Code:
<class name="Resource">
<id type="long" name="id" column="resource_id">
<generator class="increment" />
</id>
<timestamp name="lastUpdateTime" source="db"/>
<property name="identifier"/>
<many-to-one name="previousRevision" class="Resource" cascade="all" lazy="proxy" />
<many-to-one name="nextRevision" class="Resource" />
<bag name="tasks" table="demand_resource">
<key property-ref="identifier" column="resource_identifier" unique="false"/>
<many-to-many class="Demand" unique="false"
where="nextRevision is NULL" property-ref="identifier" column="demand_identifier"/>
</bag>
</class>
Code:
<class name="Demand">
<id type="long" name="id" column="demand_id">
<generator class="increment" />
</id>
<timestamp name="lastUpdateTime" source="db"/>
<property name="identifier"/>
<many-to-one name="previousRevision" class="resource" cascade="all" lazy="proxy" />
<many-to-one name="nextRevision" class="resource" />
<bag name="resources" table="demand_resource">
<key property-ref="identifier" column="demand_identifier" unique="false"/>
<many-to-many class="resources" unique="false"
where="nextRevision is NULL" property-ref="identifier" column="resource_identifier"/>
</bag>
</class>
Identifier is a UUID, and the revisions are made by a factory copying al necessary fields. and updating next and previous revision.
This is just a small demo extraction of my real implementation, but the principle is simple like above.
Both work great, but if i want to couple them and save, i get a
Code:
java.lang.NullPointerException
at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1677)
at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:641)
Any suggestion