This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 4f38fb0a09453d38ccf02c43e9df7f78cfe5df1a Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Mar 4 18:13:31 2016 +0100 Il est possible qu'on est pas dans la table LastUpdateDate une ligne que l'on doit alors créer --- .../observe/ObserveTopiaPersistenceContext.java | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaPersistenceContext.java b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaPersistenceContext.java index 32e3f6e..6ca60d4 100644 --- a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaPersistenceContext.java +++ b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaPersistenceContext.java @@ -22,6 +22,7 @@ package fr.ird.observe; * #L% */ +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import fr.ird.observe.entities.LastUpdateDate; import fr.ird.observe.entities.LastUpdateDateTopiaDao; @@ -76,11 +77,26 @@ public class ObserveTopiaPersistenceContext extends AbstractObserveTopiaPersiste public <E extends ObserveEntity> void updateLastUpdateDate(Class<E> entityType, Date date) { LastUpdateDateTopiaDao dao = getDao(LastUpdateDate.class, LastUpdateDateTopiaDao.class); - LastUpdateDate lastUpdateDate = dao.findUniqueByType(entityType.getName()); - if (log.isInfoEnabled()) { - log.info("Change LastUpdateDate: " + date + " for entity type: " + entityType.getName()); + String entityTypeName = entityType.getName(); + Optional<LastUpdateDate> optionalLastUpdateDate = dao.forTypeEquals(entityTypeName).tryFindUnique(); + LastUpdateDate lastUpdateDate; + if (!optionalLastUpdateDate.isPresent()) { + + lastUpdateDate = dao.newInstance(); + lastUpdateDate.setLastUpdateDate(date); + lastUpdateDate.setType(entityTypeName); + dao.create(lastUpdateDate); + if (log.isInfoEnabled()) { + log.info("Add LastUpdateDate: " + date + " for entity type: " + entityTypeName); + } + } else { + + lastUpdateDate = optionalLastUpdateDate.get(); + if (log.isInfoEnabled()) { + log.info("Change LastUpdateDate: " + date + " for entity type: " + entityTypeName); + } + lastUpdateDate.setLastUpdateDate(date); } - lastUpdateDate.setLastUpdateDate(date); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.