-->
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: Filter with no parameters
PostPosted: Fri May 08, 2009 11:41 pm 
Newbie

Joined: Fri Mar 27, 2009 4:29 pm
Posts: 7
Hi all -
This seems simple but I don't see any examples. I am trying to set up a Filter using annotations, to implement a soft-delete scheme.

Here is the definition:

Code:
// To my understanding, this is a global definition and can appear in any mapped @Entity
@FilterDef(name="filterDeleted", defaultCondition="deleteDate is null",parameters={})
...
    // The @Filter declaration I have tried on the property definition and on the target class
    @OneToMany(mappedBy="question",fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @Filter(name="filterDeleted")
    public List<Answer> getAnswers() {
      return answers;
    }


...and activated from a generic Dao as...
Code:
                Filter filter = hbmSession.enableFilter("filterDeleted");


However, this configuration has no effect. The Filter is ignored and nothing is logged.

Every example I've seen around includes a parameter in the condition. Is this required? What I hope to achieve is a fetch method in the dao ignoring deleted records. As a fetch, it only gets a primary key, i.e. get(Long).

Can anyone see something missing here? Thanks for any ideas.


Top
 Profile  
 
 Post subject: Re: Filter with no parameters
PostPosted: Sun May 10, 2009 9:37 pm 
Newbie

Joined: Fri Mar 27, 2009 4:29 pm
Posts: 7
Looks like it was a stupid problem, of course. Where I had placed the filter activation statement wasn't always getting executed; once I moved it in my dao, it started working. So, the examples posted above are legitimate and function fine. Hope this helps someone.


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.