Hello,
I wrote a POJO (named "Codes") which uses a wrapper objects for Strings ("TextWrapper").
Code:
public class Codes {
private TextWrapper value;
//other values
//setter, getter for all properties
//equals, hashCode
}
and
Code:
public class TextWrapper {
private String text;
setText(), getText(), equals(), hashCode()
}
My problem is the setter-method for the value property. When I define the setValue(String newValue) like
Code:
setValue(String newValue) {
this.value = new TextWrapper(newValue);
}
everything works fine.
But when I try to prevent the instantiation of new TextWrapper objects with the code
Code:
setValue(String newValue) {
if (this.value == null)
this.value = new TextWrapper(newValue);
else
this.value.setText(newValue);
}
the update will be lost when I call a flush or commit.
All involved classes have implemented equals and hash methods. What else can I do to tell hibernate that the value is dirty and the database needs an update?
Thanks in advance,
Björn
Hibernate version: 3.2.3ga
Code between sessionFactory.openSession() and session.close():Code:
Codes c = codesDAO.read(id);
c.setValue("something new");
commit();