Hi,

The following code is working

                ICriteria criteria = session.CreateCriteria(typeof
(Organization));
                criteria.CreateAlias("Addresses", "alist");
                criteria.CreateAlias("alist.items", "add");
                criteria.Add(Expression.Like("add.State", "U%"));
                return criteria.List<Organization>();

but when I want to code the same in HQL I get an error "could not
resolve property: items of:". The hql is given below

                string sql = "from Organization as o join fetch
o.Addresses a join fetch a.items x where x.Address1 like 'adr1'";
                IQuery query = session.CreateQuery(sql);
                return query.List<Organization>();

The mapping I am using is as follows

 <class name="Organization" table="Organization" lazy="false">
    <id name="OrganizationID" column="OrganizationID" type="int">
      <generator class="native"/>
    </id>
    <property name="OrganizationName" column="OrganizationName"
type="String" not-null="true"></property>
    <component name="Addresses">
      <bag name="items" table="OrgAddressMap" lazy="false" cascade
="save-update" access="field">
        <key column="OrganizationID"/>
        <many-to-many class="Address" column="AddressID"/>
      </bag>
     </component>
  </class>

Any idea's why? Is the HQL statement wrong?

Thanks

Anurag



--~--~---------~--~----~------------~-------~--~----~
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