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: Parent Child criteria for one to many.
PostPosted: Fri Aug 24, 2007 2:54 pm 
Newbie

Joined: Fri Nov 04, 2005 4:13 pm
Posts: 6
Platform Setup:
1.2:
SQL Server 2005:

I have a parent child one to many relationship setup and it is working correctly. What I need to do is run a filter on the parent that only selects parents that do not have child records equal to a criteria.

Where should I start to filter the child records?

Say I have a list of Parents(Mothers) and I want to filter out mothers that have a child named John an iCriteria?

I have the iCriteria object started:
NHibernate.ICriteria crit;
crit = RateChart.Engine.Manager.GetSession().CreateCriteria(typeof(RateChart.Common.Rate))

I would send database scheam and mappings, but I currently do not have access to them. I am working with a data access dll sent to me that connects to the DB. I will work on getting the information, but till then can anyone get me started.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 24, 2007 4:41 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
try this

Code:
DetachedCriteria childnot = (new DetachedCriteria(typeof(Child))).Add( Expression.Eq( "Name", "John" ).CreateAlias( "Parent", p ).Add( Projections.Property( "p.ID" ));
session.CreateCriteria( typeof( Parent ) ).Add( Subqueries.PropertyNotIn( "ID", childnot ) );


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.