-->
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: Nested new in hql queries
PostPosted: Sat Nov 18, 2006 10:14 am 
Newbie

Joined: Sat Nov 18, 2006 10:03 am
Posts: 3
Hi!
Is it possible to do nested instantiation (new()...) in a select??

The real case: I have a query like this

Code:
select distinct
    new SomeStrangeObject(
        (select count(id) from SomeObject where date=current_date()),
        (select count(id) from SomeObject where date<current_date()),
        (select count(id) from SomeObject where date>current_date()),
    )
from SomeObject


with a single new SomeStrangeObject(): I would like to rewrite the query like this one:

Code:
select distinct
    new SomeStrangeObject(
        new Map(
            (select count(id) from SomeObject where date=current_date()),
            (select count(id) from SomeObject where date<current_date()),
            (select count(id) from SomeObject where date>current_date()),
        )
    )
from SomeObject


So my SomeStrangeObject class can have only a single constructor with one Map parameter
instead of one constructor for any number of parameters...

I've read in the forum of some patch that let do this but the post refers to 2004 and
hibernate 2, and it seems (=looking at the changelog) this feature is not present in
the newest releases of hibernate...
thank you everybody for helps and suggestions!!
A.


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.