I have this problem with JPA Query. DER
Customers make purchases and can purchase products with a limit of 1 unit per purchase per day. This is my Native Query:
@Query("SELECT p FROM Producto p where p.idProducto not in (SELECT c.detalles FROM Compra c"
" JOIN c.detalles det" " where (c.cliente=?1 and (DATE(c.fecha) = CURRENT_DATE()))"
" GROUP BY det.id_producto" " HAVING (sum(det.cantidad<=1)))")
List<Producto> getProductosHabilitadosPorCliente(int idCliente);
ERROR: expecting CLOSE, found '<=' near line 1, column 278.
Thanks!!
CodePudding user response:
The solution:
@Query("SELECT p FROM Producto p WHERE p.idProducto NOT IN (SELECT d.producto FROM Compra c JOIN c.detalles d WHERE ((c.cliente.idCliente=?1) AND (DATE(c.fecha)=CURRENT_DATE())) GROUP BY d.producto HAVING SUM(d.cantidad)>=3")")