-->
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.  [ 8 posts ] 
Author Message
 Post subject: @FilterDef @Filters
PostPosted: Thu Mar 22, 2007 1:09 pm 
Newbie

Joined: Thu Mar 22, 2007 12:41 pm
Posts: 4
Hi does anyone know where to find good documentation for use of hibernate's @FilterDef notation?

Any examples on how to use it would be greatly appreciated.

Thank you

Vaughn


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 5:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The annotations ref doc should have some rudimentary explanation
The core ref doc a more detailed one
The unit test suite has some live examples
and Java Persistence with Hibernate describe them too.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 4:04 am 
Newbie

Joined: Thu Mar 22, 2007 12:41 pm
Posts: 4
Thank you for the reply

Do you know the URLs for them?


How would I filter out dates?

For example

@Entity
@FilterDef(name="getRiskWithoutArchiveDateSet" )
@Filters( {
@Filter(name="withoutArchive", condition="archiveDateTime = null")

} )

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 10:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Did you search for them?

http://www.hibernate.org/5.html

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 11:51 am 
Newbie

Joined: Thu Mar 22, 2007 12:41 pm
Posts: 4
All I could find is the following

When the collection use an association table as a relational representation, you might want to apply the filter condition to the association table itself or to the target entity table. To apply the constraint on the target entity, use the regular @Filter annotation. However, if you wan to target the association table, use the @FilterJoinTable annotation.

@OneToMany
@JoinTable
//filter on the target entity table
@Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length")
//filter on the association table
@FilterJoinTable(name="security", condition=":userlevel >= requredLevel")
public Set<Forest> getForests() { ... }


So I did the following om my risk class:

public class Risk extends BaseEntity {


@JoinColumn(name = "objective", referencedColumnName = "id")
@ManyToOne(fetch = FetchType.EAGER)
@FilterJoinTable(name="withoutArchiveDate", condition="archiveDateTime is null")
private Objective objective;


no luck so far

Regards vaughn


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is not association table in your case, a simple filter should work, but filter on ToOne associations should be placed on the associated entity, not on the association.
can you open a JIRa issue so that I update the doc?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 10:45 am 
Newbie

Joined: Thu Mar 22, 2007 12:41 pm
Posts: 4
Hi
Emmanuel

Thank for the reply

How do you post a JIRA Issue?

I have placed the filter on an objective object which has many risk objects.


@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@FilterJoinTable(name="withoutArchive", condition="archiveDateTime is null")
@OneToMany(mappedBy = "objective", fetch = FetchType.LAZY)
private Set<Risk> risks;


Which gives me an error.

Thanks Vaughn


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 11:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://opensource.atlassian.com/projects/hibernate/secure/Dashboard.jspa

I was refering to
@Filter
@Entity
public class Objective

_________________
Emmanuel


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