1
I honestly have a certain difficulty with comics, and I need a JPQL that returns only one record. I have a Price entity and a Product entity. I need to bring the last registered price by the user. I put a date and an ID, I imagine it could be the last ID or even the last registered date (I have a date). But how do I do it ? My BD is MYSQL and I am using Hibernate, CDI and JSF.
Price list:
id | dateLanking | value | .... product_id |
public Preco findByIdProdutoUltimoPreco(Integer produtoId) {
TypedQuery<Preco> query = em.createQuery(
"????",
Preco.class);
query.setParameter("pid", produtoId);
return query.getSingleResult();
}