Commit 3b2e2c88 authored by LAVENIER's avatar LAVENIER
Browse files

Merge branch 'release/1.6.5'

parents fa5f3fc1 dd8a3351
......@@ -3,7 +3,7 @@
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
<packaging>pom</packaging>
<name>SUMARiS</name>
<description>SUMARiS :: Maven parent</description>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<artifactId>sumaris-core-extraction</artifactId>
......
......@@ -3,7 +3,7 @@
<parent>
<artifactId>sumaris-pod</artifactId>
<groupId>net.sumaris</groupId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -3,7 +3,7 @@
<parent>
<artifactId>sumaris-pod</artifactId>
<groupId>net.sumaris</groupId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<artifactId>sumaris-core-shared</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<artifactId>sumaris-core</artifactId>
......
......@@ -453,27 +453,22 @@ public class ReferentialDaoImpl
return source;
}
@Cacheable(cacheNames = CacheNames.REFERENTIAL_MAX_UPDATE_DATE_BY_TYPE)
@Cacheable(cacheNames = CacheNames.REFERENTIAL_MAX_UPDATE_DATE_BY_TYPE, key = "#entityName")
public Date maxUpdateDate(String entityName) {
Preconditions.checkNotNull(entityName, "Missing entityName argument");
// Get entity class from entityName
Class<? extends IReferentialEntity> entityClass = getEntityClass(entityName);
try {
// Get entity class from entityName
Class<? extends IReferentialEntity> entityClass = getEntityClass(entityName);
CriteriaBuilder builder = getEntityManager().getCriteriaBuilder();
CriteriaQuery<Timestamp> criteriaQuery = builder.createQuery(Timestamp.class);
Root<? extends IReferentialEntity> root = criteriaQuery.from(entityClass);
criteriaQuery.select(root.get(IReferentialEntity.Fields.UPDATE_DATE));
criteriaQuery.orderBy(builder.desc(root.get(IReferentialEntity.Fields.UPDATE_DATE)));
String hql = String.format("SELECT max(%s) FROM %s",
IReferentialEntity.Fields.UPDATE_DATE,
entityClass.getSimpleName());
try {
return IterableUtils.first(getEntityManager().createQuery(criteriaQuery)
.setMaxResults(1)
.getResultList() // DO NOT use getSingleResult, because table can be null
);
return (Timestamp)getEntityManager().createQuery(hql).getSingleResult();
}
catch (Exception e) {
// Table is empty: return null
logger.error("Error while getting max(updateDate) from " + entityName, e);
return null;
}
}
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<artifactId>sumaris-server</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</parent>
<artifactId>sumaris-test-shared</artifactId>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment