pass query from MYSQL to JPQL?

0

Good afternoon, my query is the following I have the following query in MYSQL

 SELECT 'producto'.'NOMBRE' NOMBRE_PRODUCTO, 'ordentrabajo_producto'.'CANTIDAD' CANTIDAD, 'cliente'.'NOMBRE' NOMBRE_CLIENTE
 FROM 'ordentrabajo_producto'
 INNER JOIN 'ordentrabajo' 
 ON 'ordentrabajo_producto'.'ID_ORDENTRABAJO' = 'ordentrabajo'.'ID'
 INNER JOIN 'producto'
 ON 'ordentrabajo_producto'.'ID_PRODUCTO' = 'producto'.'ID'
 INNER JOIN 'cliente'
 ON 'ordentrabajo'.'ID_CLIENTE' = 'cliente'.'ID'
 WHERE 'ordentrabajo'.'FECHA_ORDEN_TRABAJO' BETWEEN ('2017-09-01 00:00:00') AND ('2017-09-30 00:00:00');

and I want to pass it to JPQL language in the following way

OrdentrabajoProducto o INNER JOIN Ordentrabajo  ot ON o.idOrdentrabajo =    ot.id INNER JOIN Producto p ON o.idProducto = p.id INNER JOIN Cliente c ON ot.idCliente = c.id WHERE ot.fechaOrdenTrabajo BETWEEN :startDate AND :endDate

But I get a null if I want to show a list with the query    Information: ERROR: Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.NullPointerException]. Internal Exception: java.lang.NullPointerException

method

  public void listenerBotonBuscarProductoPorFecha(){

    if (capturarFechaDesde != null && capturarFechaHasta != null) {
        String namedQuery = "OrdentrabajoProducto.findByRangoFechas";
        Map<String, Object> parametros = new HashMap<>();
        parametros.put("startDate", capturarFechaDesde);
        parametros.put("endDate", capturarFechaHasta);
        ordenTrabajoProductoListFecha = ordentrabajoProductoFacade.findByNamedQuery(namedQuery, parametros);
    } else {
        lanzarMensajeError("Debe Ingresar un Rango de Fechas de Orden de Trabajo");
    }


}
    
asked by Alexander Gil Tafur 04.10.2017 в 23:23
source

0 answers