Boa tarde Galera.
Estou precisando de ajuda na hora de criar a query.
preciso fazer uma consulta pelo nome do paciente. Tenho uma entidade Paciente e outra FichaZika. FichaZika tem a chave estrangeira do Paciente. como faço a consulta pelo nome?
public List getByPagination(int firstResult, int maxResults,String nome) {
EntityManager em = JPAUtil.getEntityManager();
List fichaZika;
try {
fichaZika = em.createQuery("select f from FichaZika f where f.", FichaZika.class)
.setFirstResult(firstResult - 1)
.setMaxResults(maxResults)
.getResultList();
} catch (RuntimeException ex) {
throw new DAOException("Erro ao buscar dados no banco: " +
ex.getMessage(), ErrorCode.SERVER_ERROR.getCode());
} finally {
em.close();
}
if (fichaZika.isEmpty()) {
throw new DAOException("Página com Fichas vazia.",
ErrorCode.NOT_FOUND.getCode());
}
return fichaZika;
}