Thanks Germán!
That did the trick.

Strange behavior in HQL, though.
It has to be an implementation detail (i.e. not easy to "guess" the type if
there are no references to it)
Fabio, is that it?

   Diego


On Wed, Nov 18, 2009 at 16:25, Germán Schuager <[email protected]> wrote:

> http://blog.schuager.com/2008/12/polymorphic-query-using-interfaces.html
>
> On Wed, Nov 18, 2009 at 4:20 PM, Diego Mijelshon 
> <[email protected]>wrote:
>
>> According to the docs, querying on IFoo should return instances from all
>> the types that implement IFoo, even if there's no reference to IFoo in the
>> mappings.
>>
>> Here's what I'm trying to map:
>>
>> *public interface IFoo { int Foo { get; set; } }*
>> *public class X : IFoo { public virtual int Foo { get; set; } }*
>> *public class Y : IFoo { public virtual int Foo { get; set; } }*
>> *
>> *
>> *<class name="X">*
>> * **<id column="id" type="int">*
>> * **<generator class="identity"/>*
>> * **</id>*
>> * **<property name="Foo"/>*
>> *</class>*
>> *<class name="Y">*
>> * **<id column="id" type="int">*
>> * **<generator class="identity"/>*
>> * **</id>*
>> * **<property name="Foo"/>*
>> *</class>*
>>
>> But when I try to CreateQuery("from IFoo"), I get an exception:
>>
>> *Unhandled Exception: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: IFoo
>> is not mapped [from IFoo]*
>> *   at
>> NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.RequireClassPersister(String
>> name)*
>> *   at NHibernate.Hql.Ast.ANTLR.Tree.FromElementFactory.AddFromElement()*
>> *   at NHibernate.Hql.Ast.ANTLR.Tree.FromClause.AddFromElement(String
>> path, IASTNode alias)*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.CreateFromElement(String
>> path, IASTNode pathNode, IASTNode alias, IASTNode propertyFetch)*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElement()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElementList()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromClause()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement()*
>> *   at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()*
>> *   at
>> NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(HqlParseEngine parser,
>> String collectionRole)*
>> *   at
>> NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2
>> replacements, Boolean shallow, String collectionRole)*
>> *   at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2
>> replacements, Boolean shallow)*
>> *   at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, String
>> collectionRole, Boolean shallow, IDictionary`2 enabledFilters,
>> ISessionFactoryImplementor factory)*
>> *   at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String
>> queryString, Boolean shallow, IDictionary`2 enabledFilters)*
>> *   at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query,
>> Boolean shallow)*
>> *   at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String
>> queryString)*
>>
>> What am I doing wrong?
>>
>>    Diego
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

--

You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to