0

Could someone help me, i'm trying create a query to recovery all entries with some date... everything works fine except as i try:

criteriaQuery.select(root).where(builder.equal(root.get("dadosBoleto").get("dataVencimento").as(Date.class), new Date()));

or

criteriaQuery.select(root).where(builder.equal(root.get("dadosBoleto").<Date>get("dataVencimento"), new Date()));

When i execute this statement i haven't any data even existing the this criteria.

My entity with dataVencimento

@Temporal(TemporalType.DATE)
@Column(name = "data_vencimento", nullable = false)
@NotNull(message = "Data inválida")
private Date dataVencimento;
//getters and setters

1 Answer 1

1

Solved!

I've added the parameter to query ParameterExpression<Date> date = builder.parameter(Date.class); and manager.createQuery(criteriaQuery).setParameter(date, new Date(), TemporalType.DATE).getResultList();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.