I have a class which holds raw byte[] data, which will occasionally be updated for version changes. The modification can be made automaitically in the 'setData' method, when the object is first loaded from the database, but how can I be sure it will be saved back? Will Hibernate call the 'getData' method and compare, or is there an easy way to set the 'data' field as dirty, so that that data is saved when the transaction ends?
Hibernate version: 3.1.3
Mapping document:
Code:
<class name="Raw" table="raw">
<id name="id">
<generator class="native"/>
</id>
<property name="data" not-null="true"/>
</class>
Pojo class:Code:
public class Raw {
int id;
byte[] data;
public void setData(byte[] data) {
this.data = data;
updateDataIfOld();
}
public byte[] getData() {
return data;
}
...
}