Lukasz Antoniak resolved Bug HHH-5411 as Fixed

Solution assumes that PostUpdateEvent#getOldState() method returns database state before modifications. Note that object's non-updateable properties are not re-initialized with database values after executing EntityManager#find() method. Use EntityManager#refresh() instead.

// Revision 2
em.getTransaction().begin();
entity = em.find(PropertyNotUpdatableEntity.class, entity.getId());
entity.setData("modified data");
entity.setConstantData1(null);  // @Column(updatable = false)
em.merge(entity);
em.getTransaction().commit();

// Revision 3
em.getTransaction().begin();
entity = em.find(PropertyNotUpdatableEntity.class, entity.getId()); // Use EntityManager#refresh() instead.
// Here entity.getConstantData1() returns null and it will cause Envers to operate incorrectly (put null in the audit table).
em.getTransaction().commit();

If described behavior is unacceptable, please reopen this ticket. To fix this I would have to execute SELECT statement to retrieve actual values for all non-updateable columns before saving audit data (decreases performance).

Change By: Lukasz Antoniak (07/Jun/12 7:46 AM)
Resolution: Fixed
Fix Version/s: 4.1.5
Assignee: Adam Warski Lukasz Antoniak
Status: Open Resolved
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira