-->
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: session.createFilter() fails for umodifiable collections
PostPosted: Thu Jul 22, 2010 3:19 pm 
Newbie

Joined: Thu Jul 22, 2010 3:07 pm
Posts: 1
Hi,

I am trying to query the number of children in a parent/child relationship with a filter. I am using field access and the getChildren() getter in my parent entity returns an unmodifiable collection set (all by the book). Except that the createFilter() method fails with this exception:

Code:
    [junit] The collection was unreferenced
    [junit] org.hibernate.QueryException: The collection was unreferenced
    [junit]     at org.hibernate.impl.SessionImpl.getFilterQueryPlan(SessionImpl.java:1464)
    [junit]     at org.hibernate.impl.SessionImpl.createFilter(SessionImpl.java:1274)


Here's the code:
Code:
        Long num = (Long) getSession()
                    .createFilter(parent.getChildren(), "select count(*)")
                    .uniqueResult();


Modifying the getChildren() method to return the actual collection works but that breaks the design/constraint. Is there any other way to go about this?

Thanks.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.