-->
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.  [ 6 posts ] 
Author Message
 Post subject: @Filter in EntityManager
PostPosted: Thu Mar 23, 2006 5:31 am 
Newbie

Joined: Tue Jan 03, 2006 7:30 am
Posts: 18
Location: Budapest, Hungary
I have defined a filter via @FilterDef and assigned it to an entity class through @Filter. I can't find a way to enable them via a persistence context though, without getting hold of the underlying Session -- and IIRC it is implementation-specific whether I can access it. (I'm using Glassfish which does, or at least used to, return a proxy to the EM implementation instead of a direct reference.) Can it be done?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:26 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Filter is much Hibernate specific stuff.
I looked under hints (http://www.hibernate.org/hib_docs/entit ... le/#d0e773), but it is not there.
So I think you cannot use it without referencing Session.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:54 am 
Newbie

Joined: Tue Jan 03, 2006 7:30 am
Posts: 18
Location: Budapest, Hungary
Re-reading what I wrote, I guess I wasn't too exact. I have nothing against accessing the Session and calling methods on it, What I can't do is calling something like ((EntityManagerImpl) em).getSession() to get a reference. I don't know any other way, though.

I've thought about adding a query hint that can be used to enable certain filters for the duration of that specific query, but I wanted to check first if there is some way I didn't notice. This solution isn't nice -- IMO, hints should only influence how a query is executed, and should not change the query substantially. But it's the least wrong way I could think of. (Unless the spec changes since the PFD include some means to access similar implementation-specific features. I don't know where to check this, though, or even whether I can check these changes.)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 9:10 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Try casting your EM to this interface - since it should be exposed.

public interface HibernateEntityManager extends EntityManager {
public Session getSession();
}


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 9:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The next spec provides a em.getDelegate() method that will provide access to the Hibernate EM implementation( no wrapper )
They probablya re spec compliant in their CVS

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 11:14 am 
Newbie

Joined: Tue Jan 03, 2006 7:30 am
Posts: 18
Location: Budapest, Hungary
emmanuel wrote:
The next spec provides a em.getDelegate() method that will provide access to the Hibernate EM implementation( no wrapper )
They probablya re spec compliant in their CVS


Actually, it is there since build 38 or so, I just didn't spot this addition. Thanks.


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