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.  [ 3 posts ] 
Author Message
 Post subject: Where condition on Set
PostPosted: Thu Apr 29, 2010 10:58 am 
Newbie

Joined: Sat Mar 27, 2010 11:51 am
Posts: 6
Hi people,

I have a problem with a query:

I have a table called "A" (and the java class) which has inside a Set<B>.

The table "B" (and the associated java class) has an attribute for example a dateBirth.

Now I need to query row from table "A" adding some constraints on A's attributes and also on B's attribute but I don't know if it's possible or how to do it.

Code:
obj = session.createQuery("from Cliente as cl where cl.dataCancellazione is null and kits.dataCancellazione is null ").list();


The Class Cliente contains "private Set<Kit> kits = new HashSet<Kit>(0);"

The Class "Kit" contains an attribute named "dataCancellazione"

Thanks a lot
AlexGiul


Top
 Profile  
 
 Post subject: Re: Where condition on Set
PostPosted: Thu Apr 29, 2010 5:17 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It's possible if you use a join: from Cliente as cl join cl.kits as kit where ....

See http://docs.jboss.org/hibernate/stable/ ... yhql-joins for some good examples.


Top
 Profile  
 
 Post subject: Re: Where condition on Set
PostPosted: Mon May 10, 2010 9:14 am 
Newbie

Joined: Sat Mar 27, 2010 11:51 am
Posts: 6
Hi all, NordBorg

I tried with this code in where clause:

where ut.filiales.idFiliale='1' and ut.flagAbilitato='1'

but I get this stack:

Code:
org.hibernate.QueryException: illegal attempt to dereference collection [utente0_.ID_UTENTE.filiales] with element property reference [idFiliale] [from it.hibernate.beans.Utente as ut  where ut.filiales.idFiliale='1' and ut.flagAbilitato='1' and 1=1]
        at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:46)
        at org.hibernate.hql.ast.tree.DotNode.checkLhsIsNotCollection(DotNode.java:512)
        at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:221)
        at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)



why?How can I solve it?

Thanks,
AlexGiul


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