-->
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: Criteria problem : collection was not an association
PostPosted: Mon Sep 05, 2005 4:23 am 
Newbie

Joined: Mon Sep 05, 2005 3:20 am
Posts: 1
Location: Liege, Belgium
Hi everybody !

I'm currently having a problem with the construction of a criteria.
I have an Object called X which have a list of Y element. Y is a composite-element with reference to Z element.
I have to construct a query which search any X objects which have at least 1 Z element in common with the list of Z elements that I pass in parameter.

The mapping is the following :

Code:
<class name="X" table="x">
        ...
        <list name="elements" table="elements" cascade="all">
            <key column="x"/>
            <list-index column="index"/>
            <composite-element class="Y">
                <property name="date" type="java.util.Date">
                    <column name="date" sql-type="date"/>
                </property>
                <many-to-one class="Z">
                    <column name="z"/>
                </many-to-one>
             </composite-element>
        </list>
</class>


And the query is the following :

Code:
criteria = session.createCriteria(X.class);
criterion = null;
for (Z zTemp : listParameters) {
   if (criterion == null) criterion = Restrictions.eq("z", zTemp);
   else criterion = Restrictions.or(criterion, Restrictions.eq("z", zTemp));
}
criteria.createCriteria("elements").add(criterion);
return criteria.list();


If I execute this query, I have the following error :

Code:
org.hibernate.MappingException: collection was not an association: X.elements
   at org.hibernate.type.CollectionType.getAssociatedEntityName(CollectionType.java:367)
   at org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathEntityName(CriteriaQueryTranslator.java:191)
   at org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:175)
   at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:81)
   at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:69)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1287)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)


Any idea ?

_________________
David Wery
Software Developer @ Manex
Rue Wagner 127, BE-4100 Boncelles, Belgium
Office : +32 4 330 37 30 - Fax : +32 4 338 06 06
Email : david.wery@manex.be
Web : http://www.manex.be


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 9:20 am 
Newbie

Joined: Tue Nov 07, 2006 10:57 am
Posts: 1
It's an open wish for improvement

http://opensource.atlassian.com/project ... se/HHH-869


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.