QuerySyntaxException: unexpected token: ON

1

When I run a query with the entity manager

entityMan.createQuery(str.toString()).getResultList().size();

I get a syntax error

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ON near line 1, 
column 534 [select catfiguras.FIGURA_OPERATIVA_ID  
,catfiguras.GRUPO_FIGURA_ID  ,catfiguras.PERMITE_BRIGADA 
,catfiguras.BTCR_FIGURA_OPERATIVA ,catfiguras.CALCULO_RECURSOS_HUMANOS
,catfiguras.EJERCICIO_ID  ,catfiguras.FIGURA_OPERATIVA_PADRE_ID 
,catfiguras.TIPO_FIGURA_OPERATIVA_ID ,catfiguras.AUDITORIA_SESION_ID 
,catfiguras.DESCRIPCION  ,catfiguras.ESTATUS  
,catfiguras.FIGURA_ANTEPROYECTO  ,catfiguras.GRUPO_PUBLICACION_ID 
,catfiguras.NOMBRE  ,catfiguras.USADMS  from CAT_FIGURAS_OPERATIVAS 
catfiguras  join DIME_CONTROL_CALCULO_FIGURAS dmcc ON  
dmcc.figura_operativa_id=catfiguras.FIGURA_OPERATIVA_ID where 1=1  and 
catfiguras.CALCULO_RECURSOS_HUMANOS=1  and 
catfiguras.FIGURA_ANTEPROYECTO=0  and catfiguras.ESTATUS=1  and 
catfiguras.TIPO_FIGURA_OPERATIVA_ID=1  AND catfiguras.EJERCICIO_ID=1 order
  by catfiguras.FIGURA_OPERATIVA_ID]

But running exactly the same query in my database Oracle runs without problems. Does anyone know how I can solve this problem?

    
asked by Ruslan López 05.12.2015 в 04:03
source

1 answer

1

I could solve it, first I put the word WITH HQL and thus gave me a more specific error, that the entity is not mapped, that is, it was not running HQL but Oracle SQL.

Fixed by changing the code to:

entityMan.createNativeQuery(str.toString()).getResultList().size();
    
answered by 05.12.2015 / 04:14
source