I have an object:
public class Data {
private long id;
private long referenceCount;
private Blob dataCache;
/* getters and setters for the above */
}
Corresponding to this is a mapping:
<hibernate-mapping>
<class name=Data" table=DATA">
<id name=id" type="long">
<column name=DATA_ID" precision="20" scale="0" />
<generator class="assigned" />
</id>
<property name="referenceCount" type="long" generated="always" insert="false" update="false">
<column name="REFERENCE_COUNT" precision="10" scale="0" not-null="true" />
</property>
<property name=dataCache" type="blob">
<column name="DATA" />
</property>
</class>
</hibernate-mapping>
The contents of 'dataCache' may be quite large.
Here's where it gets tricky: The value of referenceCount is set by a trigger, invoked by an object that has no mapping relation to the Data entity. As soon as I save this object, I must refresh a data object -- which may or may not already be loaded by the session -- in order to keep the reference count correct. Leaving aside whether this is viewed as a good idea, I have to ensure that the value of the referenceCount is up to date in my local session, but I do NOT want to reload the dataCache blob. I could set the lazy attribute on that property, but I'm not sure that it'll act the way I hope it will.
How should I do this? I guess that one way I could look at it is: "How can I remove an object from the session cache without loading that object if it isn't already there?"