Done, http://nhjira.koah.net/browse/NH-2019
Diego On Wed, Nov 18, 2009 at 17:30, Fabio Maulo <[email protected]> wrote: > Adding a JIRA ticket about the documentation issue. The proposed patch is > well welcome. > Thanks. > > > 2009/11/18 Diego Mijelshon <[email protected]> > >> It seemed weird that *CreateCriteria<IFoo>()* always works, but >> *CreateQuery("from >> IFoo")* requires the use of <import> (and, strange enough, *CreateQuery("from >> System.Object")* works always). >> >> That wasn't clear to me from the doc ( >> http://nhforge.org/doc/nh/en/index.html#queryhql-polymorphism), and after >> implementing what Germán suggested, I assumed it wasn't possible for the HQL >> parser to know what type I'm referring to if it's not declared, while >> Criteria gets the corresponding Type instance. >> >> Now, after seeing it all, it's a perfectly reasonable behavior. Only the >> docs should be more specific. >> How can I contribute to that? I feel like it's time to start giving back >> to NH :-) >> >> Diego >> >> >> >> On Wed, Nov 18, 2009 at 16:59, Fabio Maulo <[email protected]> wrote: >> >>> where is the news? I don't understand >>> http://nhforge.org/doc/nh/en/index.html#mapping-declaration-import >>> >>> 2009/11/18 Diego Mijelshon <[email protected]> >>> >>> 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]<nhusers%[email protected]> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/nhusers?hl=en. >>>> >>> >>> >>> >>> -- >>> Fabio Maulo >>> >>> -- >>> 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. >> > > > > -- > Fabio Maulo > > -- > 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=.
