-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Icriteria error (could not resolve property)
PostPosted: Thu Jul 13, 2006 12:16 pm 
Newbie

Joined: Fri Jun 30, 2006 8:37 am
Posts: 8
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 14, 2006 8:49 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Well, you don't have property UserID, do you? You have User.Id.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.