-->
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.  [ 2 posts ] 
Author Message
 Post subject: How can I use the Criteria API to replace the following HQL.
PostPosted: Thu Aug 04, 2005 11:30 am 
Beginner
Beginner

Joined: Tue Jul 12, 2005 10:27 am
Posts: 23
I haven't been able to find any good tutorials on Criteria API, but the following HQL is generated based upon the number of predicates passed in. For example, there isn't a need to do a left outer join if there are no predicates and there isn't a need to check the predicate name/value also.

I know using the Criteria API would help clean up this logic, but I can't see how to handle the left outer join.

Point will be awarded based upon an insightful answer.

Code:
select
   nt
from
   type nt,
   blah n,
   other ne
   left outer join ne.predicates
   as preds
   where n.application = ne.application and
   n.event = ne.event and
   ne.predicateCount = :count and
   n.notificationType = nt.type and
   n.application = nt.application and
   n.application = :application and
   n.event = :event and
   n.setId = preds.setId and 
   (
      (preds.name = :name0 and preds.value in (:value0, 'ANY'))
   )
group by
   nt.application,
   nt.subscriber,
   nt.type,
   nt.value
having count(*) = :having_count


Thank you!

_________________
- Richard Burton


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 11:43 am 
Beginner
Beginner

Joined: Tue Jul 12, 2005 10:27 am
Posts: 23
.setFetchMode("property", FetchMode.JOIN) // generates left outer join

Any indepth tutorials are welcomed. When I generate the property code, I'll post it to help share the information.

_________________
- Richard Burton


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.