Hello,
  I'm trying to use a hibernate filter to limit child records of an
oneToMany association.

@Entity
public Class Parent {
     ...  
     private Set<Child> childs = new HashSet<Child>();
...
@OneToMany (fetch=FetchType.EAGER)
        @JoinColumn(name = "fk_parentId")
        @Filter(name="validRecord",  condition=":field < value")
        public Set<Child> getChilds() {
                return this.Childs;
        }
        public void addChild(Child child){
                getChilds().add(child);
        }
        public void setChilds(Set<Child> _childs) {
                this.childs = _childs;
        }
} 

@Entity
@FilterDef(name="fiekd", parameters={ @ParamDef( name="field",
type="integer" ) } )
@Filters( {
    @Filter(name="validRecord", condition=":field< value")
} )
public class Child{
    ...
    private Parent parent = new Parent();
    ...
@ManyToOne()
          @JoinColumn( name="fk_parentId" )
          public Parent getParent()
          {
            return this.parent;
          }
          public void setParent( Parent parent )
          {
            this.parent = parent ;
          }
}  

How do I get this filter from the session? Do I also have to define it in
the SessionFactory from the Spring applicationContext config file? When I
just try the following:

Filter childFilter = getSession().enableFilter("validRecord");

I get an exception: Can't located filter...

Help help 

Thanks 
Yves

-- 
View this message in context: 
http://www.nabble.com/Appfuse-2-Spring-Hibernate-query-result-filter-question-tp15509067s2369p15509067.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to