-->
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.  [ 1 post ] 
Author Message
 Post subject: Spring-Hibernate-Annotation Query Filter question
PostPosted: Fri Feb 15, 2008 4:32 pm 
Newbie

Joined: Fri Feb 15, 2008 4:30 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.