-->
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: selecting "in elements(...)" as part of an HQL que
PostPosted: Wed Dec 06, 2006 7:03 am 
Newbie

Joined: Wed Dec 06, 2006 6:47 am
Posts: 1
Hi all,

I'm writing (what I think should be) a simple query, to select a number of items, as well as a boolean value of whether they occur in a collection.

I have two classes, User, and NewsItem, where User contains a many-to-many collection called readItems. I wrote the following HQL query:

select n, (n in elements(u.readItems)) from NewsItem n, User u where u.id=:id

I was expecting the result to be a List of Object[], but instead I get a list of NewsItems, so I get a ClassCastException. From this, and the generated SQL, it seems that it is not selecting the read/unread status, as desired.

I am quite new to Hibernate, so can anyone tell me how I can achieve this effect?

Thanks,
Nick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 1:53 pm 
Regular
Regular

Joined: Mon May 22, 2006 2:30 pm
Posts: 74
You are getting a list of NewsItem because that is what you are asking for with "select n" (n is a NewsItem). You won't get an array of Object when you are asking for a mapped persistent object. I can't provide detailed SQL without the mappings.


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.