Hello,
I have a problem with constructing the proper HQL for an <any> map.
Hibernate version: 1.0.2.0
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Domainmodel.Licence, Domainmodel" table="licences">
<id name="ID" column="id" type="Int32">
<generator class="native" />
</id>
<any name="IssuedTo" id-type="Int32" meta-type="Int32">
<meta-value value="1" class="Domainmodel.Application, Domainmodel"/>
<meta-value value="2" class="Domainmodel.User, Domainmodel"/>
<column name="type"/>
<column name="issued_to_id"/>
</any>
</class>
</hibernate-mapping>
To get the licences for a particular object (than can be any of the types mapped by the <any> mapping) I use:
Code:
FROM Domainmodel.Licence as licence WHERE licence.IssuedTo = :application
where :application would be set to using IQuery.SetEntity to an instance of type Domainmodel.Application.
This results in the following exception. Any ideas what the right HQL would be?
Thanks, Rodin
Full stack trace of any exception that occurs:
NHibernate.QueryException : Incorrect query syntax [SELECT licence FROM Domainmodel.Licence as licence WHERE licence.IssuedTo = :application] ----> System.ArgumentException : Item has already been added. Key in dictionary: 'licence' Key being added: 'licence' at NHibernate.Hql.QueryTranslator.Compile() at NHibernate.Hql.QueryTranslator.Compile(ISessionFactoryImplementor factory, IDictionary replacements, Boolean scalar) at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow) at NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar) at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters) at NHibernate.Impl.QueryImpl.List()