Project

General

Profile

Actions

Task #834

closed

Attribute modified isn't correctly propagate to DTO layer

Added by Ondřej Kopr over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Radek Tomiška
Category:
Audit
Target version:
Start date:
11/13/2017
Due date:
% Done:

100%

Estimated time:
Owner:

Description

Please fix behavior with propagate modified to DTO layer.

Use case:
after save entity has account management old data (only audit attributes: modified, modifier, ...).

Add this fix please also into hotfix 7.5.3 thank you.

Actions #1

Updated by Radek Tomiška over 6 years ago

  • Status changed from New to Needs feedback
  • Assignee changed from Radek Tomiška to Ondřej Kopr
  • Target version set to Forsterite (7.6.0)
  • % Done changed from 0 to 90

AuditableEntityListener is responsible for setting audit attributes into dto, respectively to entity, when persistence event is published:
- PrePersist - when new entity is saved (persist) - this event is published immediately when new entity is saved
- PreUpdate - when entity is updated (merge) - event publishing depends on hibernate flush mode setting (COMMIT, AUTO - see https://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/FlushMode.html)

I was not able to fix this issue with update (=> set modified attribute in dto immediately after save) another way, that i changed 'save' method behavior and call 'flush' method after entity is saved.
I've added new method 'saveAndFlush' into 'BaseEntityRepository' and this method is used now for saving identity and any other dtos. Now are audit properties available right after dto is created or updated.

I will add this change into develop branch only. Workaround with creating 'new DateTime()', where modified has to be used in transformation scripts, can be usen in older releases.

Could you do a feedback pls?

Actions #2

Updated by Ondřej Kopr over 6 years ago

  • Status changed from Needs feedback to Resolved
  • Assignee changed from Ondřej Kopr to Radek Tomiška
  • % Done changed from 90 to 100

I did review, your test works correctly and this attribute (like modifier, modified, etc) i get actual immediately after save.

I found problem in my case and your solution can't help me with provisioning modified attribute in new provisioning (new account):
  • after add new role with provisioning for identity, attribute modified isn't change becouse is null (for identity isn't any change),
  • next attempts with save/update identity works perfectly, modified value is actualized.

So for the project attribute last_change is best way to set your idea with 'new DateTime();' this behavior will works even if i update some attributes on contract.

Thank you Radek for flush after save, thank you, change works well.

Actions #3

Updated by Radek Tomiška over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF