-->
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: The proper HQL for <any> mapping
PostPosted: Mon Apr 24, 2006 11:05 am 
Newbie

Joined: Mon Apr 24, 2006 10:48 am
Posts: 1
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()


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.