Hibernate version: 3.2.5 ga
Mapping documents:
Code:
<class name="beans.Basicuser" table="BASICUSER">
<id name="usercode" type="java.lang.Long">
<column name="USERCODE" precision="30" scale="0" />
<generator class="TriggerGenerated" />
</id>
<property name="username" type="java.lang.String">
<column name="USERNAME" not-null="true" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" not-null="true" />
</property>
<property name="firstname" type="java.lang.String">
<column name="FIRSTNAME" not-null="true" />
</property>
<property name="middlename" type="java.lang.String">
<column name="MIDDLENAME" />
</property>
<property name="lastname" type="java.lang.String">
<column name="LASTNAME" not-null="true" />
</property>
<joined-subclass name="beans.GeneralPublicUser" table="GENERALPUBLICUSER">
<key column="USERCODE"/>
<property name="personalDescription" type="java.lang.String">
<column name="PERSONALDESCRIPTION"/>
</property>
<property name="photo" type="byte[]">
<column name="PHOTO"/>
</property>
<set name="profiles" table="PROFILE" >
<key column="USERCODE" />
<one-to-many class="beans.Profile"/>
</set>
</joined-subclass>
</class>
Goodmornign, I have a problem with the classes shown in the mapping.
The architecture of my apllication requires that hibernate is only responsible of getting objects from the database, instead insert and update operations are performed by direct sql on the database.
This is a requirement and can not be changed.
When an update is performed, I have to remove the updated object from the cache.
I used the session.evict(object) and I had no problems.
When I wrote the update of the photo field, instead, I experienced some problems:
I update the blob field in the database, call the Session.evict on the updated object.
But, when I access to the user photo the behaviour is strange: some times the new photo is presented, some others time the old one. It seems without logic. The old one, the new one, then the new one and the old one and so on.
Where is my mistake?
I can suppose that the object is not really removed from the session, but why?
I hope you can help me.
Thank you very much.