Hi everybody,
first I'll describe the scenario:
I have two POJOs A and B (A extends B). B has some methods to set a PropertyChangeListener. When this method is called it creates, if not existing, a new private object changeSupport which holds the listeners.
Code:
public final synchronized void addPropertyChangeListener(
PropertyChangeListener listener) {
if (listener == null) {
return;
}
if (changeSupport == null) {
changeSupport = new ExtendedPropertyChangeSupport(this);
}
changeSupport.addPropertyChangeListener(listener);
}
Now I retrieve an object A with hibernate and set the listeners. When I do so the debugger shows that A ist in instanceof A$$EnhanceByCGLIB$$. Later when the GUI calls a setter method (e.g. setAge()) of A to change the field the firePropertyChange method is called.
Code:
public void setAge(Integer newAge) {
Integer oldAge = age;
age = newAge;
if (newAge != null && !newAge.equals(oldAge)) {
firePropertyChange(AGE, oldAge, newAge);
}
}
And here comes the problem. Inside this method the debugger shows me that the object is an instance of A. All values are set except the changeSupport.
What is going wrong? Is ist because neither A nor B have a setter or getter for changeSupport?
Here the dao methode for loading a patient.
Code:
private Patient loadPatientById(Long id) {
Patient result;
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
result = (Patient) session.load(Patient.class, id);
// TODO remove hack to avoid close session prob
result.hashCode();
Hibernate.initialize(result);
session.getTransaction().commit();
return result;
}
I am using hibernate 3.20 with mysql 4.1.21 as DB
Thank you for any hint! I tried to keep it as short as possible. Please let me know if you need some additional information.
Kif