@Test public void testGetByHashNull() { Optional<TextFlow> tf = dao.getLatestByContentHash(LocaleCode.EN_US, "hash"); assertThat(tf.isPresent()).isFalse(); }
@SuppressWarnings("unchecked") public Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode, String contentHash) { String query = "FROM TextFlow WHERE contentHash =:contentHash AND locale.localeCode =:localeCode ORDER BY lastChanged DESC"; List<TextFlow> tfs = getEntityManager() .createQuery(query) .setParameter("contentHash", contentHash) .setParameter("localeCode", localeCode) .getResultList(); return (tfs == null || tfs.isEmpty()) ? Optional.empty() : Optional.of(tfs.get(0)); }
TextFlowDAO extends AbstractDAO<TextFlow> { @SuppressWarnings("unchecked") public Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode, String contentHash) { String query = "FROM TextFlow WHERE contentHash =:contentHash AND locale.localeCode =:localeCode ORDER BY lastChanged DESC"; List<TextFlow> tfs = getEntityManager() .createQuery(query) .setParameter("contentHash", contentHash) .setParameter("localeCode", localeCode) .getResultList(); return (tfs == null || tfs.isEmpty()) ? Optional.empty() : Optional.of(tfs.get(0)); } }
TextFlowDAO extends AbstractDAO<TextFlow> { @SuppressWarnings("unchecked") public Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode, String contentHash) { String query = "FROM TextFlow WHERE contentHash =:contentHash AND locale.localeCode =:localeCode ORDER BY lastChanged DESC"; List<TextFlow> tfs = getEntityManager() .createQuery(query) .setParameter("contentHash", contentHash) .setParameter("localeCode", localeCode) .getResultList(); return (tfs == null || tfs.isEmpty()) ? Optional.empty() : Optional.of(tfs.get(0)); } @SuppressWarnings("unused")  TextFlowDAO(); @VisibleForTesting  TextFlowDAO(EntityManager entityManager); }
TextFlowDAO extends AbstractDAO<TextFlow> { @SuppressWarnings("unchecked") public Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode, String contentHash) { String query = "FROM TextFlow WHERE contentHash =:contentHash AND locale.localeCode =:localeCode ORDER BY lastChanged DESC"; List<TextFlow> tfs = getEntityManager() .createQuery(query) .setParameter("contentHash", contentHash) .setParameter("localeCode", localeCode) .getResultList(); return (tfs == null || tfs.isEmpty()) ? Optional.empty() : Optional.of(tfs.get(0)); } @SuppressWarnings("unused")  TextFlowDAO(); @VisibleForTesting  TextFlowDAO(EntityManager entityManager); @SuppressWarnings("unchecked") Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode,
            String contentHash); }
TextFlowDAO extends AbstractDAO<TextFlow> { @SuppressWarnings("unchecked") public Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode, String contentHash) { String query = "FROM TextFlow WHERE contentHash =:contentHash AND locale.localeCode =:localeCode ORDER BY lastChanged DESC"; List<TextFlow> tfs = getEntityManager() .createQuery(query) .setParameter("contentHash", contentHash) .setParameter("localeCode", localeCode) .getResultList(); return (tfs == null || tfs.isEmpty()) ? Optional.empty() : Optional.of(tfs.get(0)); } @SuppressWarnings("unused")  TextFlowDAO(); @VisibleForTesting  TextFlowDAO(EntityManager entityManager); @SuppressWarnings("unchecked") Optional<TextFlow> getLatestByContentHash(LocaleCode localeCode,
            String contentHash);  }