I'm getting the following error with a named query, on Session start.

NHibernate.QueryException: No column name found for property [Id] for
alias [hp] [select iteminhier0_.Id as {h.Id},
                    itemlookup1_.Id as {i.Id},
                    itemlookup2_.Id as {p.Id},
                    lp_.Id as {hp.Id},
                    iteminhier0_.version as {h.Version},
                    iteminhier0_.parent_id as {h.ParentItem},
                    iteminhier0_.item_id as {h.Item},
                    iteminhier0_.expand as {h.Expand},
                    iteminhier0_.not_fitted as {h.NotFitted},
                    iteminhier0_.qty_in_parent as {h.QtyInParent},
                    iteminhier0_.sequence as {h.Sequence},
                    iteminhier0_.reference as {h.Reference},
                    iteminhier0_.created_on as {h.CreatedOn},
                    iteminhier0_.created_by as {h.CreatedBy},
                    iteminhier0_.modified_on as {h.ModifiedOn},
                    iteminhier0_.modified_by as {h.ModifiedBy},
                    iteminhier0_.uom as {h.UoM},
                    itemlookup1_.id_prefix as {i.IdPrefix},
                    itemlookup1_.id_number as {i.IdNumber},
                    itemlookup1_.id_site as {i.IdSite},
                    itemlookup1_.name as {i.Name},
                    itemlookup1_.description as {i.Description},
                    itemlookup1_.mfg_no as {i.MfgNo},
                    itemlookup1_.toplevel as {i.MajorItem},
                    itemlookup2_.id_prefix as {p.IdPrefix},
                    itemlookup2_.id_number as {p.IdNumber},
                    itemlookup2_.id_site as {p.IdSite},
                    itemlookup2_.name as {p.Name},
                    itemlookup2_.description as {p.Description},
                    itemlookup2_.mfg_no as {p.MfgNo},
                    itemlookup2_.toplevel as
{p.MajorItem},
                    lp_.link_id as {hp.ItemInHierarchy},
                    lp_.version as {hp.Version},
                    lp_.string_entry as {hp.Entry},
                    lp_.created_on as {hp.CreatedOn},
                    lp_.created_by as {hp.CreatedBy},
                    lp_.modified_on as {hp.ModifiedOn},
                    lp_.modified_by as {hp.ModifiedBy},
                    count(childlinks3_.Id) as count
                    from
                    ItemLink iteminhier0_ inner join Item itemlookup1_
on iteminhier0_.item_id=itemlookup1_.Id
                    inner join Item itemlookup2_ on
iteminhier0_.parent_id=itemlookup2_.Id
                    left outer join ItemLinkPosition lp_ on
iteminhier0_.id = lp_.link_id
                    left outer join ItemLink childlinks3_ on
iteminhier0_.item_id=childlinks3_.parent_id
                    where (itemlookup2_.Id
= :parent )
                    group by
                    iteminhier0_.Id ,
                    iteminhier0_.version ,
                    iteminhier0_.expand ,
                    iteminhier0_.not_fitted ,
                    iteminhier0_.qty_in_parent ,
                    iteminhier0_.sequence ,
                    iteminhier0_.reference ,
                    iteminhier0_.created_on ,
                    iteminhier0_.created_by ,
                    iteminhier0_.modified_on ,
                    iteminhier0_.modified_by ,
                    iteminhier0_.uom ,
                    itemlookup2_.Id ,
                    itemlookup2_.id_prefix ,
                    itemlookup2_.id_number ,
                    itemlookup2_.id_site ,
                    itemlookup2_.name ,
                    itemlookup2_.description ,
                    itemlookup2_.mfg_no ,
                    itemlookup2_.toplevel ,
                    itemlookup1_.Id ,
                    itemlookup1_.id_prefix ,
                    itemlookup1_.id_number ,
                    itemlookup1_.id_site ,
                    itemlookup1_.name ,
                    itemlookup1_.description ,
                    itemlookup1_.mfg_no ,
                    itemlookup1_.toplevel,
                    iteminhier0_.parent_id,
                    iteminhier0_.item_id,
                    lp_.id ,
                    lp_.link_id ,
                                                  lp_.version,
                    lp_.string_entry,
                                                  lp_.created_on,
                    lp_.created_by,
                                                  lp_.modified_on,
                    lp_.modified_by
                    order by iteminhier0_.sequence, lp_.created_on]
   at
NHibernate.Loader.Custom.Sql.SQLQueryParser.ResolveCollectionProperties(String
aliasName, String propertyName, IDictionary fieldResults, ISqlLoadable
elementPersister, ISqlLoadableCollection currentPersister, String
suffix, String persisterSuffix)
   at NHibernate.Loader.Custom.Sql.SQLQueryParser.SubstituteBrackets()
   at NHibernate.Loader.Custom.Sql.SQLQueryParser.Process()
   at
NHibernate.Loader.Custom.Sql.SQLCustomQuery..ctor(INativeSQLQueryReturn[]
queryReturns, String sqlQuery, ICollection`1 additionalQuerySpaces,
ISessionFactoryImplementor factory)
   at
NHibernate.Engine.Query.NativeSQLQueryPlan..ctor(NativeSQLQuerySpecification
specification, ISessionFactoryImplementor factory)
   at
NHibernate.Engine.Query.QueryPlanCache.GetNativeSQLQueryPlan(NativeSQLQuerySpecification
spec)
   at NHibernate.Impl.SessionFactoryImpl.CheckNamedQueries()
A first chance exception of type 'NHibernate.HibernateException'
occurred in NHibernate.dll


The query in question is shown in the error detail, here is the full
mapping:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Proxima.Domain" assembly="Proxima.Domain" >
  <class name="ItemInHierarchy" table="ItemLink" select-before-
update="true" >
    <id name="Id">
      <generator class="guid.comb" />
    </id>
    <property name="Version" column="version" />

    <many-to-one name="ParentItem" class="ItemLookup"
column="parent_id" fetch="join" />
    <many-to-one name="Item" class="ItemLookup" column="item_id"
fetch="join"  />

    <property name="Expand" column="expand"/>
    <property name="NotFitted" column="not_fitted" />
    <property name="QtyInParent" column="qty_in_parent" />
    <property name="Sequence" column="sequence" />
    <property name="Reference" column="reference" />
    <property name="UoM" column="uom" />
    <property name="CreatedOn" column="created_on" />
    <property name="CreatedBy" column="created_by" />
    <property name="ModifiedOn" column="modified_on" />
    <property name="ModifiedBy" column="modified_by" />

    <bag name="ChildLinksBag" table="ItemLink" inverse="true"
lazy="true" cascade="all" >
      <key column="item_id" />
      <one-to-many class="ItemInHierarchy"/>
    </bag>

    <bag name="ParentLinksBag" table="ItemLink" inverse="true"
lazy="true" cascade="none" >
      <key column="parent_id" />
      <one-to-many class="ItemInHierarchy"/>
    </bag>

    <!--positions-->
    <bag name="PositionsBag" table="ItemLinkPosition" inverse="true"
lazy="true" cascade="all" batch-size="100" >
      <key column="link_id" />
      <one-to-many class="ItemInHierarchyPosition"/>
    </bag>


  </class>

  <resultset name="HierarchyItem">
    <return alias="h" class="ItemInHierarchy" />
    <load-collection alias="hp" role="ItemInHierarchy.PositionsBag" />
    <return-join alias="i" property="h.Item" />
    <return-join alias="p" property="h.ParentItem" />
    <return-scalar column="count" type="long" />
  </resultset>


  <sql-query name="HierarchyChildrenWithCount" resultset-
ref="HierarchyItem">
    <![CDATA[select iteminhier0_.Id as {h.Id},
                    itemlookup1_.Id as {i.Id},
                    itemlookup2_.Id as {p.Id},
                    lp_.Id as {hp.Id},
                    iteminhier0_.version as {h.Version},
                    iteminhier0_.parent_id as {h.ParentItem},
                    iteminhier0_.item_id as {h.Item},
                    iteminhier0_.expand as {h.Expand},
                    iteminhier0_.not_fitted as {h.NotFitted},
                    iteminhier0_.qty_in_parent as {h.QtyInParent},
                    iteminhier0_.sequence as {h.Sequence},
                    iteminhier0_.reference as {h.Reference},
                    iteminhier0_.created_on as {h.CreatedOn},
                    iteminhier0_.created_by as {h.CreatedBy},
                    iteminhier0_.modified_on as {h.ModifiedOn},
                    iteminhier0_.modified_by as {h.ModifiedBy},
                    iteminhier0_.uom as {h.UoM},
                    itemlookup1_.id_prefix as {i.IdPrefix},
                    itemlookup1_.id_number as {i.IdNumber},
                    itemlookup1_.id_site as {i.IdSite},
                    itemlookup1_.name as {i.Name},
                    itemlookup1_.description as {i.Description},
                    itemlookup1_.mfg_no as {i.MfgNo},
                    itemlookup1_.toplevel as {i.MajorItem},
                    itemlookup2_.id_prefix as {p.IdPrefix},
                    itemlookup2_.id_number as {p.IdNumber},
                    itemlookup2_.id_site as {p.IdSite},
                    itemlookup2_.name as {p.Name},
                    itemlookup2_.description as {p.Description},
                    itemlookup2_.mfg_no as {p.MfgNo},
                    itemlookup2_.toplevel as
{p.MajorItem},
                    lp_.link_id as {hp.ItemInHierarchy},
                    lp_.version as {hp.Version},
                    lp_.string_entry as {hp.Entry},
                    lp_.created_on as {hp.CreatedOn},
                    lp_.created_by as {hp.CreatedBy},
                    lp_.modified_on as {hp.ModifiedOn},
                    lp_.modified_by as {hp.ModifiedBy},
                    count(childlinks3_.Id) as count
                    from
                    ItemLink iteminhier0_ inner join Item itemlookup1_
on iteminhier0_.item_id=itemlookup1_.Id
                    inner join Item itemlookup2_ on
iteminhier0_.parent_id=itemlookup2_.Id
                    left outer join ItemLinkPosition lp_ on
iteminhier0_.id = lp_.link_id
                    left outer join ItemLink childlinks3_ on
iteminhier0_.item_id=childlinks3_.parent_id
                    where (itemlookup2_.Id
= :parent )
                    group by
                    iteminhier0_.Id ,
                    iteminhier0_.version ,
                    iteminhier0_.expand ,
                    iteminhier0_.not_fitted ,
                    iteminhier0_.qty_in_parent ,
                    iteminhier0_.sequence ,
                    iteminhier0_.reference ,
                    iteminhier0_.created_on ,
                    iteminhier0_.created_by ,
                    iteminhier0_.modified_on ,
                    iteminhier0_.modified_by ,
                    iteminhier0_.uom ,
                    itemlookup2_.Id ,
                    itemlookup2_.id_prefix ,
                    itemlookup2_.id_number ,
                    itemlookup2_.id_site ,
                    itemlookup2_.name ,
                    itemlookup2_.description ,
                    itemlookup2_.mfg_no ,
                    itemlookup2_.toplevel ,
                    itemlookup1_.Id ,
                    itemlookup1_.id_prefix ,
                    itemlookup1_.id_number ,
                    itemlookup1_.id_site ,
                    itemlookup1_.name ,
                    itemlookup1_.description ,
                    itemlookup1_.mfg_no ,
                    itemlookup1_.toplevel,
                    iteminhier0_.parent_id,
                    iteminhier0_.item_id,
                    lp_.id ,
                    lp_.link_id ,
                    lp_.version,
                    lp_.string_entry,
                    lp_.created_on,
                    lp_.created_by,
                    lp_.modified_on,
                    lp_.modified_by
                    order by iteminhier0_.sequence, lp_.created_on

    ]]>
  </sql-query>

</hibernate-mapping>

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

Reply via email to