-->
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.  [ 3 posts ] 
Author Message
 Post subject: StackTrace Hibernate
PostPosted: Thu Feb 05, 2009 10:56 pm 
Newbie

Joined: Sun Feb 01, 2009 12:15 pm
Posts: 3
Hi,

I am using Hibernate 3.2, and I would like to know if it's possible to get an expression for an attribute pass as a parameter :

ex: In sql (it is very easy)

SELECT (t.A+t.B+t.C > 0) from table t

Where the expression (t.A+t.B+t.C > 0) is a boolean return by default by the query (true or false).

I am unable to do it with HQL. I guess I have to use a transformer to stock the boolean but I am not even at the stage where the request with HQL is generate.

Thanks!,

jepau.

Here is the StackTrace :

2009-02-05 21:45:34,987 ERROR [org.hibernate.hql.PARSER] - line 1:32: unexpected token: >


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 8:40 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Why do u want to use the expression in the select clause? Cant you put it in the where clause?

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject: Put an expression in the select clause
PostPosted: Sat Feb 07, 2009 8:17 am 
Newbie

Joined: Sun Feb 01, 2009 12:15 pm
Posts: 3
Yes, you can, but it seems that it must be an expression such as a calculation, here is the full details of what I am trying to do with the
Junit test case include, that might help...


Here is the Hibernate query :
return sessionFactory.getCurrentSession().createQuery("select ( (year(pet.birthDate) - year(pet.birthDate)) + "+ "(month(pet.birthDate) - month(pet.birthDate)) + "+"(day(pet.birthDate) - day(pet.birthDate)) + "+
"(hour(pet.birthDate) - hour(pet.birthDate)) ) > 24 as dateValue, pet.birthDate as realDate from Pet pet").setResultTransformer( Transformers.aliasToBean(DateDTO.class) ).list();

Here is the Java StackTrace (I am sparing you the junit Java scrap that does'nt mean anything and only pin-point the hibernate error) :


2009-02-07 07:12:16,714 ERROR [org.hibernate.hql.PARSER] - <AST>:1:195: unexpected AST node: >
2009-02-07 07:12:16,714 WARN [org.springframework.test.context.TestContextManager] - Caught exception while allowing TestExecutionListener

In short, the operator > seems to cause issue, but that`s a boolean in the expression I want to rerieve, if I do only the calculation as an expression it pass, may somebofy helps...


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

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.