-->
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: criteria queries createAlias() and outer joins
PostPosted: Fri Sep 16, 2005 2:29 pm 
Newbie

Joined: Wed Sep 14, 2005 10:39 am
Posts: 4
It seems pretty clear to me that createAlias() is designed to FORCE an "inner join". See:


The question I have (echoed in the above threads) is "why?"

My case is ideally suited to Criteria queries... I've got a complex entity that can be queried in dozens of different ways. I've got a class that specifies the query components and I can process them into a quite elegant Criteria query doing stuff like:

Code:
   if (queryPart != null)  {
       crit.add(Restrictions.eq("somePart1", "test"));
   }

   if (queryPart2 != null)  {
       Junction j = Restrictions.conjunction();
       j.add(Restrictions.ge("somePart2", queryPart2.getValMin()));
       j.add(Restrictions.le("somePart2", queryPart2.getValMax()));
       crit.add(j);
   }

   ...


and on and on... However, this doesn't work if it inner joins when I add an alias (to query on attributes of my children).

I know I can do this in HQL, but it seems much more messy because I have to build up an HQL string, and then setParameter() appropriately, etc.

So... What should I do?

Thanks,
Andy


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.