-->
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.  [ 7 posts ] 
Author Message
 Post subject: Ignore / Disable listeners for particular persistence unit?
PostPosted: Mon Jan 11, 2010 8:46 pm 
Newbie

Joined: Mon Jan 11, 2010 8:34 pm
Posts: 6
JBoss 5.1.0
Hibernate Search 3.1.1 (with EntityManager/JPA)

Our persistence.xml has two persistence units, one for normal read / write operations (Let's call this A), the second is for reading uncommitted data from the data base (isolation level set to TRANSACTION_READ_UNCOMMITTED) (B).

Hibernate Search is working like a champ for A as intended. However hibernate search is also trying to attach to / automatically create another set of indexes for the second persistence unit, B. We don't need hibernate search to do anything with B.

Is there any way to tell Hibernate Search ignore a particular persistence unit in persistence.xml? Or a way to tell Hibernate Search to only attach to particular persistence units?

I've read the manual and Hibernate Search in Action. I wasn't able to find anything like this.


Top
 Profile  
 
 Post subject: Re: Ignore / Disable listeners for particular persistence unit?
PostPosted: Tue Jan 12, 2010 8:27 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, you can prevent Hibernate Search to register himself as listener on the EntityManager;
from the reference docs:
Code:
3.7.1. Enabling Hibernate Search

Hibernate Search is enabled out of the box when using Hibernate Annotations or Hibernate EntityManager. If, for some reason you need to disable it, set hibernate.search.autoregister_listeners to false. Note that there is no performance penalty when the listeners are enabled even though no entities are indexed.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Ignore / Disable listeners for particular persistence unit?
PostPosted: Tue Jan 12, 2010 9:37 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Does persistence unit B contain also classes which are annotated with @Indexed? Or are you using the same classes in the two different units?
Generally Search does not know about persistence units or JPA in general. All it cares is whether there are indexed (classes annotated with @Indexed) classes. Maybe it would be possible to write a custom FullTextIndexEventListener which does not trigger index updates when an event originates from a certain persistence unit. However, that's just a guess at the moment, since I am not sure whether this information will be available or not.

--Hardy


Top
 Profile  
 
 Post subject: Re: Ignore / Disable listeners for particular persistence unit?
PostPosted: Tue Jan 12, 2010 11:52 am 
Newbie

Joined: Mon Jan 11, 2010 8:34 pm
Posts: 6
Thanks to both of you for the response. Setting "hibernate.search.autoregister_listenersfalse" to false was exactly what I needed. Quite frankly I'm a bit embarrassed that I missed that. I suppose I've been staring at too many docs in the past week or two. Thanks.


Top
 Profile  
 
 Post subject: Re: Ignore / Disable listeners for particular persistence unit?
PostPosted: Tue Jan 12, 2010 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
no problem, you're welcome :)

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Ignore / Disable listeners for particular persistence unit?
PostPosted: Thu Jan 28, 2010 8:45 pm 
Newbie

Joined: Thu Jan 28, 2010 8:40 pm
Posts: 2
Hardy, I didn't quite understand your post. I am trying to use Hibernate with tomcat eclipse, and I heard that you need to disable listeners first. I am a newbie and have been looking for a good resource on that stack but haven't been able to find any, including the one I just linked to, which is of middling quality.


Top
 Profile  
 
 Post subject: Re: Ignore / Disable listeners for particular persistence unit?
PostPosted: Thu Jan 28, 2010 8:46 pm 
Newbie

Joined: Thu Jan 28, 2010 8:40 pm
Posts: 2
Actually-- scratch that, I'm an idiot. I searched for the wrong thing. TY anyway Hardy, et al.


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