/** * {@inheritDoc} */ @Override public Long findId(long methodIdentId, long methodSensorTypeIdentId, boolean updateTimestamp) { TypedQuery<Long> query = getEntityManager().createNamedQuery(MethodIdentToSensorType.FIND_ID_FOR_METHOD_ID_AND_METOHD_SENSOR_TYPE_ID, Long.class); query.setParameter("methodIdentId", methodIdentId); query.setParameter("methodSensorTypeIdentId", methodSensorTypeIdentId); List<Long> results = query.getResultList(); if (updateTimestamp && CollectionUtils.isNotEmpty(results)) { Query updateQuery = getEntityManager().createNamedQuery(MethodIdentToSensorType.UPDATE_TIMESTAMP); updateQuery.setParameter("ids", results); updateQuery.executeUpdate(); } if (1 == results.size()) { return results.get(0); } else { return null; } } }