JPA @Transient fields being cleared before @PreUpdate method is called
I solved this by setting updatable und insertable to false on the "transient" field, so in your case this would be:
@Column(name = "password", insertable = false, updatable = false)
private String password;
Therefore a table @column is required (which is kind of ugly) but it will never be filled (which was important in my case for security reasons).
I tested against Hibernate 4.3.4.Final and it worked for me. The field value was useable in my EntityLister @PrePersist and @PreUpdate methods but was not stored in the database.
Hope that helps anybody having similar problems.
As mentioned in the above answer, this is by design in the spec. EclipseLink contains an event (postMerge) that is not part of the JPA spec that should be called in the right point in the cycle for you. In EclipseLink 2.1 The Descriptor Event Adaptor class can be registered using the regular @EventListeners annotation, pre 2.1 you will need to add the even using EclipseLink native API.
@EntityListeners({
a.b.MyEventListener.class,
})
package a.b;
import org.eclipse.persistence.descriptors.DescriptorEvent;
import org.eclipse.persistence.descriptors.DescriptorEventAdapter;
public class MyEventListener extends DescriptorEventAdapter {
public void postMerge(DescriptorEvent event) {
//event.getSession();
//event.getObject();
//event.getOriginalObject();
}
}