-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Cast from datetime to date using hibernate and informix
PostPosted: Thu Jun 13, 2013 2:46 am 
Newbie

Joined: Wed Jan 25, 2012 5:35 am
Posts: 3
I have a problem with the 'cast' expresion in Hibernate, when I execute the next HQL:

Code:
SELECT new es.xunta.surex.vo.informes.ActividadUsuarioAuxVO(usu.codusu, cast(au.dataaudit as date), fun.idfunaudit, count(*))
FROM AuditAnotacion au, FunAuditoria fun, Usuario usu
WHERE au.funAuditoria.idfunaudit=fun.idfunaudit
AND  au.usuario.idusu=usu.idusu
AND  usu.unidade.iduni=:iduni
AND  au.dataaudit between :desde AND :hasta
GROUP BY 1, 2, 3
ORDER BY 1, 2, 3


Hibernate 'translates' it into this SQL:

Code:
select
    usuario2_.codusu as col_0_0_,
    cast(auditanota0_.dataauditasdate) as col_1_0_,
    funauditor1_.idfunaudit as col_2_0_,
    count(*) as col_3_0_
from
    audit_anotacion auditanota0_,
    fun_auditoria funauditor1_,
    usuario usuario2_
where
    (
        auditanota0_.idfunaudit=funauditor1_.idfunaudit
    )
    AND(
        auditanota0_.idusu=usuario2_.idusu
    )
    AND(
        usuario2_.iduni=?
    )
    AND(
        auditanota0_.dataaudit between ? AND ?
    )
group by
    1 ,
    2 ,
    3
order by
    1 ,
    2 ,
    3


And I get this error:

Quote:
A syntax error has occurred.
org.hibernate.exception.SQLGrammarException: could not execute query


Because It's parsing the cast like this 'cast(auditanota0_.dataauditasdate)' instead of 'cast(auditanota0_.dataaudit as date)'

I'm using org.hibernate.dialect.InformixDialect, so what's wrong?

Could you help me? Please. Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.