-->
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: HQL, maps and index-many-to-many
PostPosted: Wed Jun 02, 2004 10:03 am 
Newbie

Joined: Wed Jun 02, 2004 9:37 am
Posts: 2
I have the following mapping, in my class SubscriberImpl :

Code:
<map name="subscriberEmailings" table="subscriberemailing" lazy="true" inverse="true" cascade="all">
  <key column="subscriber"/>
  <index-many-to-many class="com.fullsix.newsletter.impl.EmailingImpl" column="emailing"/>
  <composite-element class="com.fullsix.newsletter.impl.SubscriberEmailingImpl">
    <property name="status" type="int" column="status" not-null="true"/>
  </composite-element>
</map>


I try to query my database with the following HQL query :

Code:
session.iterate("SELECT s" +
                "  FROM com.fullsix.newsletter.impl.SubscriberImpl AS s, " +
                "       com.fullsix.newsletter.impl.EmailingImpl AS e " +
                " WHERE s.subscribersList.id=? " +
                "   AND e.id=? " +
                "   AND s.status=1 " +
                "   AND s.subscriberEmailings[e].status=?",
                new Object[]{getList().getId(), getId(), new Integer(SubscriberEmailing.SEND_WAIT)},
                new Type[]{Hibernate.STRING, Hibernate.STRING, Hibernate.INTEGER});


It doesn't work, and gives the following exception :

Code:
net.sf.hibernate.QueryException: illegally dereferenced collection element [SELECT s  FROM com.fullsix.newsletter.impl.SubscriberImpl AS s  WHERE s.subscribersList.id=?    AND e.id=?    AND s.status=1    AND s.subscriberEmailings[e].status=?]
        at net.sf.hibernate.hql.WhereParser.getElementName(WhereParser.java:173)
        at net.sf.hibernate.hql.WhereParser.continuePathExpression(WhereParser.java:453)
        at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:197)
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
        at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
[...]


Is there anything to transform the query so that it is equivalent ?

I'm using hibernate 2.1.2 with PostgreSQL 7.4.2 on Linux.
Thanks,
-- Etienne


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