Ver Mensaje Individual
  #14 (permalink)  
Antiguo 27/10/2009, 09:58
Pelirr
 
Fecha de Ingreso: diciembre-2008
Mensajes: 233
Antigüedad: 15 años, 4 meses
Puntos: 1
Respuesta: pasar String a Date

Hola, algo debo hacer mal al hacer la primera consulta porque me dá el siguiente error :

java.lang.IllegalArgumentException: node to traverse cannot be null!

cuando llega a la linea:

this.getEntityManager().createQuery(consultaformat ofecha);

del método:

@SuppressWarnings("unchecked")
public Collection<SalidaResiduo> obtenerSalidasResiduosDeFecha(Date fecha) throws JpaDaoException {
try {
DateFormat formatoFecha = new SimpleDateFormat("dd/MM/yyyy");
DateFormat formatoFechaDestino = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String textoFecha = formatoFecha.format(fecha);
Date fechaDesde = formatoFechaDestino.parse(textoFecha + " 00:00:00");
Date fechaHasta = formatoFechaDestino.parse(textoFecha + " 23:59:59");
String textoConsulta = "from SalidaResiduo srE where srE.fechasalida between "+fechaDesde+" and "+fechaHasta;
//Para que el formato de fecha se mantenga durante la sesión primero se hace esta consulta
String consultaformatofecha = "ALTER SESSION SET NLS_DATE_FORMAT = 'DD/MM/YYYY'";
this.getEntityManager().createQuery(consultaformat ofecha);

Query consulta = this.getEntityManager().createQuery(textoConsulta) ;

return consulta.getResultList();
} catch (Exception e) {
throw new JpaDaoException(e);
}
}

si no he entendido mal, primero tengo que decirle como quiero las fechas durante mi sesion con "ALTER ....", y después hacer la consulta que yo quiera (en este caso, "from SalidaResiduo...". ¿Tendría utilizar el ALTER ... de otro modo? Muchas gracias, un saludo