-->
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: Hibernate Filter
PostPosted: Wed Sep 10, 2008 12:37 pm 
Newbie

Joined: Wed Sep 10, 2008 12:11 pm
Posts: 1
Hi!

My problem is as follows. Thanks in advance for any kind of hint!

I have a Java Class which represents a group, containing a Set of Objects of type "Employee".
In my application you are able to delete such employees, but just in a logic way: A existing delete date indicates that a employee has been deleted.

Let's say there is a group called "testGroup", which contains some deleted employees because they where deleted at some time since the group has been created.

When I now call testGroup.getEmployees() Hibernate loads ALL Employess (lazy loading), also the deleted ones.

The reason for that is simple to understand but is there any way to tell Hibernate that he doesn't have to consider the employees with the delete date != null?

I tried to use Hibernate filters but it didn't work. Is it simply not possible to apply filters on Collection elements or did I something wrong?

From my point of view that situation is a general problem in many appplications, isnt it?

Cheers,
Robert


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2008 2:08 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I am not sure what you mean with that you "have tried Hibernate filters". Have you tried adding the "where" attribute on the <set>, <map> or whatever type of collection you have? Eg. something like:

Code:
<set ....
   where="not date is null"
/>


Another option is to use the Session.createFilter() as described by http://www.hibernate.org/hib_docs/v3/re ... -filtering


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.