-->
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.  [ 5 posts ] 
Author Message
 Post subject: could not resolve property - error
PostPosted: Thu Jan 03, 2008 9:38 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
Hello,

I've got a problem using ICriteria. I get the error

Quote:
{"could not resolve property: ProgramId.TitleOriginal of: DemeterDomain.TMaterial"}


when trying to get data this way:

Code:
mCriteria.Add(Expression.Like("ProgramId.ProgramId", 1));
mCriteria.Add(Expression.Like("ProgramId.TitleOriginal", "zwo"));
tmpIList = mCriteria.List();


Using Criteria with only the first "ProgramId"-expression or using session.find works perfectly:

Code:
object b = session.Find("from TMaterial as TMaterial where TMaterial.ProgramId.TitleOriginal = 'zwo'");


My Mapping files look like this:

Code:
TMaterial.hmb.xml
<many-to-one name="ProgramId" column="PROGRAM_ID" class="TProgramDetails" />

TProgram.hbm.xml
<id name="ProgramId" column="PROGRAM_ID" type="Decimal" unsaved-value="0">
         <generator class="assigned"/>
      </id>
<property column="TITLE_ORIGINAL" type="String" name="TitleOriginal" length="250" />


Does anybody have an idea what I'm doing wrong?

Thank you for any advice...

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 10:28 am 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
Change mCriteria.Add(Expression.Like("ProgramId.TitleOriginal", "zwo"));
to
mCriteria.Add(Expression.Like("TMaterial.TitleOriginal", "zwo"));

_________________
Please rate if it helped


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 10:59 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
I'm sorry, but this doesn't work either...

I've already tried as well to use

Code:
mCriteria.Add(Expression.Like("TMaterial.ProgramId.TitleOriginal", "zwo"));


without any result (getting the same error)...

I just don't understand why I can use the "TitleOriginal"-property in the "find", but not in the "criteria"-approach...


Top
 Profile  
 
 Post subject: Re: could not resolve property - error
PostPosted: Wed Jan 09, 2008 12:35 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Code:
mCriteria.AddAlias("ProgramId", "p");
mCriteria.Add(Expression.Like("p.ProgramId", 1));
mCriteria.Add(Expression.Like("p.TitleOriginal", "zwo"));
tmpIList = mCriteria.List();


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 12:48 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
I think it should be:
Code:
mCriteria.CreateAlias("ProgramId", "p");


in the first line or alternatively it can be done by specifying:

Code:
mCriteria.CreateCriteria("ProgramId");
mCriteria.Add(Expression.Like("ProgramId", 1));
mCriteria.Add(Expression.Like("TitleOriginal", "zwo"));
tmpIList = mCriteria.List();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.