-->
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: HQL, "all elements" parameters
PostPosted: Thu Jul 26, 2007 8:36 am 
Newbie

Joined: Wed May 25, 2005 12:01 pm
Posts: 6
Hibernate version: 3.2.4sp1

I am trying to use "all elements" expression in HQL and pass it a parameterList of entities, like this:

Code:
Object result = RequestContext.getHibernateSession().createQuery(
"select 1 from CalendarEventPersonImpl cal where publicEvent = true and creator = all elements(:persons) and calendarEventType.id IN (:calendarEventTypeList) and startTime < current_timestamp() and endTime > current_timestamp()")
        .setParameterList("persons", persons)
        .setParameterList("calendarEventTypeList", new String[] {"EVENT_HOLIDAY", "EVENT_ABSENCE", "EVENT_VACATION"})
        .setMaxResults(1)
        .uniqueResult();


(I am trying to get information if all persons in the list are currently absent).

But executing this I get the following error message back:
Code:
expecting IDENT, found ':' near line 1, column 125 [select 1 from org.comp.organization.CalendarEventPersonImpl cal where publicEvent = true and creator = all elements(:persons) and calendarEventType.id IN (:calendarEventTypeList) and startTime < current_timestamp() and endTime > current_timestamp()]


Obviously I am using "all elements" expression the wrong way. Could not find much example code in docs, all I could find is an example to pass a collection to it directly, not via parameter.
Is it possible at all?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 9:50 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
I get the impression "elements" can't accept a parameterized value, only a subquery or (ref docs) "the element or index set of a collection".

Why not use an IN clause for creator?


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.