Hi,
Can anyone help me.
I have two data objects - Notification and NotificationPrimaryAddressee.
These 2 ojects are in a one to manty relationship. (i.e. notification = one, NotificationPrimaryAddressee = many.
I am attempting to do a criteria search:- return all notifications in a descending date ordder for a particular User. (The user Id is held in the NotificationPrimaryAddressee data object)
xxx
When I attempt to run the criteria query I get the following error:-
An unhandled exception of type 'NHibernate.QueryException' occurred in nhibernate.dll
Additional information: could not resolve property:UserID of :SCF.FMS.DataModel.NotificationPrimaryAddressee
The code I use to run the criteria query is as follows:-
IList arrNotificationList = new ArrayList();
NHibernate.ISession session = SessionManagement.getSession(); //get handle to current session
DataModel.Notification Notification = new DataModel.Notification();
ICriteria criteria = session.CreateCriteria(typeof(DataModel.Notification)); //any notification data will be returned in reverse date order criteria.AddOrder(Order.Desc("NotificationDate") ); criteria.CreateAlias("NotificationPrimaryAddressees","PA"); criteria.Add( Expression.Eq("PA.UserID", objNotificationSearchCriteria.SearchUserID) ); return criteria.List();
Here's a copy of the 2 mapping files:-
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="SCF.FMS.DataModel.Notification, DataModel" table="Notification">
<id name="Id" type="Int32" unsaved-value="0">
<column name="NotificationID" sql-type="int" not-null="true" unique="true" index="PK_Notification"/>
<generator class="native" />
</id>
<property name="NotificationSubject" type="String">
<column name="NotificationSubject" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="NotificationDate" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate">
<column name="NotificationDate" sql-type="datetime" not-null="false"/>
</property>
<property name="NotificationText" type="String">
<column name="NotificationText" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="NotificationStatus" type="String">
<column name="NotificationStatus" length="50" sql-type="varchar" not-null="false"/>
</property>
<bag name="NotificationReadMarks" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationReadMark, DataModel"/>
</bag>
<bag name="NotificationSecondaryAddressees" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationSecondaryAddressee, DataModel"/>
</bag>
<bag name="NotificationNotes" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationNote, DataModel"/>
</bag>
<bag name="Proposals" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.Proposal, DataModel"/>
</bag>
<bag name="Countries" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.Country, DataModel"/>
</bag>
<bag name="NotificationPrimaryAddressees" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="NotificationID"/>
<one-to-many class="SCF.FMS.DataModel.NotificationPrimaryAddressee, DataModel"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="SCF.FMS.DataModel.NotificationPrimaryAddressee, DataModel" table="NotificationPrimaryAddressee">
<id name="Id" type="Int32" unsaved-value="0">
<column name="NotificationPrimaryAddresseeID" sql-type="int" not-null="true" unique="true" index="PK_NotificationPrimaryAddressee"/>
<generator class="native" />
</id>
<property name="NotificationType" type="String">
<column name="NotificationType" length="50" sql-type="varchar" not-null="false"/>
</property>
<property name="NotificationEmailAddress" type="String">
<column name="NotificationEmailAddress" length="50" sql-type="varchar" not-null="false"/>
</property>
<many-to-one name="User" class="SCF.FMS.DataModel.User, DataModel">
<column name="UserID" sql-type="int" not-null="false"/>
</many-to-one>
<many-to-one name="Notification" class="SCF.FMS.DataModel.Notification, DataModel">
<column name="NotificationID" sql-type="int" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
Thanks in advance for your assistance
|