-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria: Is it necessary to have an association Class?
PostPosted: Wed Aug 08, 2007 8:59 am 
Newbie

Joined: Fri Aug 03, 2007 9:35 am
Posts: 8
I have 3 tables. Job, Person, JobPerson (=association table)

When I need all jobs made by certain person, I write this:

ICriteria critMain = session.CreateCriteria(typeof(Job));
Disjunction orMain = new Disjunction();
critMain.Add(orMain); //there will be another conditions later

DetachedCriteria subquery = DetachedCriteria.For(typeof(JobPerson));
subquery.Add(Expression.Eq("IdPerson", requestedPersonId));
subquery.SetProjection(Projections.Property("IdJob"));

orMain.Add(Subqueries.PropertyIn("IdJob", subquery));

IList aaaaa = critMain.List();

It works OK, but I have to declare association class JobPerson (which maps the association table with IdJob and IdPerson)

My question is: Is it really necessary to write the association Class JobPerson or is there any simplier way???

I have to add, that I work with Criterias.

Thanks for any answer.


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

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.