-->
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: "WHERE" condition is ignored when mapping to a collection
PostPosted: Wed May 15, 2013 9:09 am 
Newbie

Joined: Wed May 15, 2013 8:48 am
Posts: 1
I have a relationship of one department to many students expressed as following:

Student
Code:
<hibernate-mapping>
  <class name="com.example.Student" table="STUDENTS" where="active = 'Y'">
  ...
  </class>
</hibernate-mapping>

Department
Code:
<hibernate-mapping>
  <class name="com.example.Department" table="DEPARTMENTS">
   
    ...
   
    <set name="students>
      <one-to-many class="com.example.Student" />
    </set>

  </class>
</hibernate-mapping>


When I run this code, a department returns all students including ones where active != 'Y' (it disregards the information in the student mapping). Is this expected behaviour? I thought that the where condition on the student mapping would force only the active ones to be returned. I am using 3.2.5.


Top
 Profile  
 
 Post subject: Re: "WHERE" condition is ignored when mapping to a collection
PostPosted: Fri May 17, 2013 6:09 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Could you try below two solutions,.

1) Adding class level filter in the child mapping xml.
2) Adding Set level filter in Parent mapping xml.

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


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.