diff options
author | Martin Taal | 2012-11-24 13:20:00 +0000 |
---|---|---|
committer | Martin Taal | 2012-11-24 13:20:00 +0000 |
commit | c538b93f13bbfb48724335f01858922901d7e4bc (patch) | |
tree | b34e03ba84926bee61338f1811e77b115f69213b /hibernate/org.eclipse.emf.teneo.hibernate | |
parent | 3b072e8581488049f4eae4179dbace162b198f22 (diff) | |
download | org.eclipse.emf.teneo-c538b93f13bbfb48724335f01858922901d7e4bc.tar.gz org.eclipse.emf.teneo-c538b93f13bbfb48724335f01858922901d7e4bc.tar.xz org.eclipse.emf.teneo-c538b93f13bbfb48724335f01858922901d7e4bc.zip |
Set version to 1 for new objects in the audit entry
Diffstat (limited to 'hibernate/org.eclipse.emf.teneo.hibernate')
-rwxr-xr-x | hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java index 7419d3270..bf7031d0a 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditProcessHandler.java @@ -101,21 +101,24 @@ public class AuditProcessHandler implements AfterTransactionCompletionProcess, final Object version = session.getEntityPersister( dataStore.toEntityName(auditHandler.getEClass(entity)), entity).getVersion(entity); - if (version == null) { - if (auditKind == TeneoAuditKind.ADD) { - // start from one. - auditWork.setVersion(1); - } else { - final long tmpVersion = System.currentTimeMillis(); - // set dummy version, does not happen often - auditWork.setVersion(tmpVersion); - } + if (auditKind == TeneoAuditKind.ADD) { + // start from one. + auditWork.setVersion(1); + } else if (version == null) { + final long tmpVersion = System.currentTimeMillis(); + // set dummy version, does not happen often + auditWork.setVersion(tmpVersion); } else if (version instanceof Timestamp) { auditWork.setVersion(((Timestamp) version).getTime()); } else { auditWork.setVersion(((Number) version).longValue()); } + // increase the version by one for cdo, it can be seen as a state change + if (auditKind == TeneoAuditKind.DELETE) { + auditWork.setVersion(1 + auditWork.getVersion()); + } + final List<AuditWork> auditWorks; if (workQueue.containsKey(session.getTransaction())) { auditWorks = workQueue.get(session.getTransaction()); |