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