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: SQL to HQL with subquerys
PostPosted: Wed Nov 24, 2010 6:18 am 
Newbie

Joined: Wed Nov 24, 2010 6:14 am
Posts: 1
I've read about the lack of support for subquerys with HQL, but anyway, anyone could tell me if this SQL query could be implemented with HQL?

I've already made some testing but with no success...don't know if I'm in the right path...

SQL (working)

Code:
SELECT
    foo.id as fooId,
    foo.name AS fooName,
    chan.name AS chanName,
    (SELECT DISTINCT
        foo_lang.VALUE
     FROM
        foo_lang
     WHERE
        foo_lang.foo_id = fooId AND
        foo_lang.lang_id = 1) as EN
FROM
    foo
INNER JOIN chan ON foo.chan_id = chan.id


HQL (not working)

Code:
select new
    Map(o.id as id,
        o.name as fooName,
        c.name as chanName,
        (select fl.value from foo_lang fl where fl.id.fId = id and fl.id.lId = 1) as EN)
from
    foo o
    left join o.chan c


It gives:

org.hibernate.TypeMismatchException: left and right hand sides of a binary logic operator were incompatibile [big_decimal : component[lId,rId]]

Is about the subquerys or something else?

Thanks in advance.


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.