org.hibernate.hql.ast.QuerySyntaxException: unexpected token

0

I have this error when getting the format of a date, I adapted my date with simple date format and I do not get my result:

  

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 2017 near line 1, column 101 [SELECT v FROM com.sa.model.crm.Offer v WHERE 1 = 1 AND v.typeOfferent = 0 AND v. Interview date 2017-00-07] at org.hibernate.hql.ast.QuerySyntaxException.convert (QuerySyntaxException.java:31) at org.hibernate.hql.ast.QuerySyntaxException.convert (QuerySyntaxException.java:24) at org.hibernate. hql.ast.ErrorCounter.throwQueryException (ErrorCounter.java:59) at

This is my method:

public void FiltrarPorTipo (){


     Date d = getFechaDeEntrevista();
     SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
             String d2 = format.format(d);
     System.out.println(d2);


    hql = "SELECT v FROM Oferente v WHERE 1 = 1";
    hql +=(getTipoOferente() != null)? " AND v.tipoOferente= "+ getTipoOferente():"";

    hql +=(getFechaDeEntrevista()!= null)? " AND v.fechaDeEntrevista "+ d2:"";



    oferentePorTipoDias = entityManager.createQuery(hql).getResultList();

    System.out.println("************ Consulta: " + hql);

    dtRp.put("oferentePorTipoDias", oferentePorTipoDias);
}
    
asked by Nestor Melara 20.06.2017 в 18:30
source

1 answer

1

The error that is observed with the naked eye is that in the last AND it seems that you are not adding the = , that is to say v.fechaDeEntrevista = ...

hql +=(getFechaDeEntrevista()!= null)? " AND v.fechaDeEntrevista =  "+ d2:"";
    
answered by 20.06.2017 в 18:56