-->
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.  [ 4 posts ] 
Author Message
 Post subject: Is it possible to use CreateCriteria on <component>?
PostPosted: Fri Sep 30, 2005 5:13 am 
Newbie

Joined: Wed Aug 31, 2005 8:23 am
Posts: 5
Location: Belgium
Hello,

I'm trying to use createCriteria API on <component> property.

I made several tests :
My component is ValidityPeriod and it contains the End Property.
Code:
ICriteria crit=NHibernateSession.CreateCriteria(typeof(DomainModel.MainObject));
crit.Add(Expression.Gt("ValidityPeriod.End",beginDate));

Then, it returns the error code :
Quote:
could not resolve property:ValidityPeriod.End


Using the typical way for association :
Code:
crit.CreateCriteria("ValidityPeriod").Add(Expression.Gt("End",beginDate));

it returns :
Quote:
not an association path: ValidityPeriod)


IS there a way to use createCriteria for Component?
or must I use HQL query or session.find ?

Thanks,
David


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 2:29 pm 
Newbie

Joined: Wed Aug 31, 2005 8:23 am
Posts: 5
Location: Belgium
I finally manage to use createCriteria on my component by implementing my own Expression object.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 7:55 am 
Newbie

Joined: Wed Jan 23, 2008 7:25 am
Posts: 2
I've also had problem with querying components.

While searching for solution, i've found this page. But in my case it didn't help.

In Cat.hbm.xml
Code:
<component name="KittensList" class="KittensList" >
   <bag name="DataList" inverse="true" cascade="all-delete-orphan" >
      <key column="CatID" />
      <one-to-many class="Kitty" />
  </bag>
</component>


In my case, search should look like this:

Code:
ICriteria crit = session.CreateCriteria(typeof(Cat));
crit.CreateCriteria("KittensList.DataList")
        .Add(Expression.Eq("KittyId", 3));
cats = crit.List();


Last edited by anelka on Wed Jan 23, 2008 8:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 7:56 am 
Newbie

Joined: Wed Jan 23, 2008 7:25 am
Posts: 2
I use it in NH 1.2


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.