-->
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.  [ 5 posts ] 
Author Message
 Post subject: Apply filter or session.load()
PostPosted: Wed Mar 23, 2011 1:40 am 
Newbie

Joined: Fri Dec 17, 2010 3:12 am
Posts: 8
Hi,

Can I apply a query filter for session.load() ?

like, session.enableFilter("filterName");
session.load();


Agreed that session.load() returns a single record.
But what if I want to check if the records is supposed to be loaded for a certain condition?
Any suggestions or alternate methods to do this?

Thanks.


Top
 Profile  
 
 Post subject: Re: Apply filter or session.load()
PostPosted: Wed Mar 23, 2011 7:46 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Why don't you use a HQL query or the criteria API ??


Top
 Profile  
 
 Post subject: Re: Apply filter or session.load()
PostPosted: Wed Mar 23, 2011 9:36 am 
Newbie

Joined: Fri Dec 17, 2010 3:12 am
Posts: 8
cz this is not a complete new development.
session.load() has been used throughout the application.

Now, a requirement has cropped up where in we need to filter out data.
dats the reason why i was trying it this way...


Top
 Profile  
 
 Post subject: Re: Apply filter or session.load()
PostPosted: Wed Mar 23, 2011 9:41 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
I guess you mean session.get(). session.load just returns a proxy and does not even query the database.

Anyway, filters do unfortunately not work on session.get() or load().

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: Apply filter or session.load()
PostPosted: Wed Mar 23, 2011 10:22 am 
Newbie

Joined: Fri Dec 17, 2010 3:12 am
Posts: 8
Exactly..
filters unfortunately don't work on session.load()/get()..

what could be the best alternative for that?
what i was trying i was..i have overriden the load() method and am firing a corresponding HQL query, thus appending filters.
I know it doesn't sound good...

But any other better suggestions?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.