@Test public void testFindAllByTags() { Collection<Audit> auditList = auditDAO.findAllByTag("tagA"); assertEquals(1, auditList.size()); assertEquals(Long.valueOf(1), auditList.stream().findFirst().get().getId()); auditList = auditDAO.findAllByTag("tagB"); assertEquals(2, auditList.size()); }
@Override public List<Audit> findAllByTag(String tag) { Query query = entityManager.createQuery("SELECT a FROM " + getEntityClass().getName() + " a " + " JOIN a.tagList t WHERE t.value = :tag"); query.setParameter("tag", tag); return query.getResultList(); }
AuditDAOImpl extends AbstractJPADAO<Audit, Long> implements AuditDAO { @Override public List<Audit> findAllByTag(String tag) { Query query = entityManager.createQuery("SELECT a FROM " + getEntityClass().getName() + " a " + " JOIN a.tagList t WHERE t.value = :tag"); query.setParameter("tag", tag); return query.getResultList(); } }
AuditDAOImpl extends AbstractJPADAO<Audit, Long> implements AuditDAO { @Override public List<Audit> findAllByTag(String tag) { Query query = entityManager.createQuery("SELECT a FROM " + getEntityClass().getName() + " a " + " JOIN a.tagList t WHERE t.value = :tag"); query.setParameter("tag", tag); return query.getResultList(); } AuditDAOImpl(); }
AuditDAOImpl extends AbstractJPADAO<Audit, Long> implements AuditDAO { @Override public List<Audit> findAllByTag(String tag) { Query query = entityManager.createQuery("SELECT a FROM " + getEntityClass().getName() + " a " + " JOIN a.tagList t WHERE t.value = :tag"); query.setParameter("tag", tag); return query.getResultList(); } AuditDAOImpl(); @Override List<Audit> findAll(); @Override List<Audit> findAll(AuditStatus status); @Override Audit findAuditWithTest(Long id); @Override List<Audit> findAllByTag(String tag); }
AuditDAOImpl extends AbstractJPADAO<Audit, Long> implements AuditDAO { @Override public List<Audit> findAllByTag(String tag) { Query query = entityManager.createQuery("SELECT a FROM " + getEntityClass().getName() + " a " + " JOIN a.tagList t WHERE t.value = :tag"); query.setParameter("tag", tag); return query.getResultList(); } AuditDAOImpl(); @Override List<Audit> findAll(); @Override List<Audit> findAll(AuditStatus status); @Override Audit findAuditWithTest(Long id); @Override List<Audit> findAllByTag(String tag);  }