-->
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: Hibernate Search and @PostPersist
PostPosted: Tue Apr 22, 2008 11:55 am 
Newbie

Joined: Fri Jun 22, 2007 7:14 am
Posts: 5
Hi all,

I'm using Hibernate Search (in Jboss Seam), and am facing problems when used together with @PostPersist, @PostUpdate, etc annotations.

When I activate the event-listeners of Hibernate Search in persistence.xml, the @Post... annotated method don't get called anymore. It's like all other event-listeners in my application are overridden by the ones of Hibernate Search.

If I remove them from the persistence.xml file, the methods get called properly, but all search-operations throw exceptions saying I need to enable the listeners. Setting indexing to manual doesn't seem to help.

Any idea how to solve this?

thx,

bram


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 6:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Bram,

maybe you could post some of your code here, or even better some test scenario? Since you are using annotation you shouldn't have to specify the listeners explicitly, but maybe there is a bug?

--hardy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 7:00 am 
Newbie

Joined: Fri Jun 22, 2007 7:14 am
Posts: 5
Ok, no problem, but it's basic code.

Here are the annotations (inside an Entity Bean).
I know this is kinda bad design, but I need it to 'block' an update (some kind of manual-dynamic cascade-implementation).

Code:
@PreUpdate
protected void doPreUpdate()
{
    this.blockParentAccess = true;
}
@PostUpdate
protected void doPostUpdate()
{
    this.blockParentAccess = false;
}


Then, here's my persistence.xml
Code:
<persistence-unit name="myPersistence">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:/myPersistenceDatasource</jta-data-source>
     
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="validate"/>
         <property name="hibernate.cache.use_query_cache" value="true"/>
         <property name="hibernate.show_sql" value="false"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="jboss.entity.manager.factory.jndi.name" value="java:/myPersistenceEntityManagerFactory"/>
         
         <!-- use a file system based index -->
         <property name="hibernate.search.default.directory_provider"
                   value="org.hibernate.search.store.FSDirectoryProvider"/>
         <property name="hibernate.search.default.indexBase"
                   value="/etc/tumboliaIndexes"/>
         <property name="hibernate.ejb.event.post-insert"
                   value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-update"
                   value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-delete"
                   value="org.hibernate.search.event.FullTextIndexEventListener"/>
      </properties>
   </persistence-unit>


So, what happens is:
The @PreUpdate method gets called, but the @PostUpdate one doesn't, except if I remove the 'hibernate.ejb.event.post-update' listener from the Hibernate config.

I've been reading that one must be careful with event-listener overriding, that it's better to add it to the listener-list, instead of replacing them, but I don't have a clue how or where to do this.

Help is welcome.

b.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 7:28 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I see you are registering the listeners "the old way";
If you have recent hibernate-annotations and entitymanager
the listeners are auto-registered.

Quote:
If I remove them from the persistence.xml file, the methods get called properly, but all search-operations throw exceptions saying I need to enable the listeners. Setting indexing to manual doesn't seem to help.

What do you mean by "removing"? I assume to comment out he last 3 properties, not using and empty value.
Which jar versions are you using? probably updating to the latest and removing any configuration about listeners could fix this.

regards,

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 8:14 am 
Newbie

Joined: Fri Jun 22, 2007 7:14 am
Posts: 5
Yes, by removing, I mean, deleting or commenting out the last three properties.
I'm using the jar-files supplied with JBoss Seam 2.0.0 GA (hibernate-commons-annotations.jar, hibernate-search.jar and lucene-core.jar).

Version numbers from the manifests:
hibernate-commons-annotations.jar: 3.0.0.GA
hibernate-search.jar: 3.0.0.GA
lucene-core.jar: 2.2.0

Will an update be affecting anything?

b.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 23, 2008 9:15 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
my personal experience is that I can update all hibernate jar (and entitymanager and lucene) in Seam 2 without worries,
most changes are bugfixes.
It is unsupported of course, but also Seam2 is not supperted yet (AFAIK).

So my suggestion is to upgrade all hibernate jars to the latests stable releases in Seam, in your project and in your application server (JBoss?).

Also switch to lucene 2.3.0.

regards,

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 24, 2008 5:44 am 
Newbie

Joined: Fri Jun 22, 2007 7:14 am
Posts: 5
Great, worked like a charm, now let's hope nothing else breaks ;-)


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.