-->
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: Hibernate Search PostDeleteEvent not firing
PostPosted: Mon Sep 19, 2011 5:29 pm 
Newbie

Joined: Mon Sep 19, 2011 5:01 pm
Posts: 2
When writing HQL Hibernate Queries, the objects are removed from the database, however they don't appeare to be deleted from the Lucene Index.(I belive this is mentioned in the Hibernate documentation).

What would be the best way to remove these objects from the Lucene directory on disk in this case?

I have tried creating a PostDeleteEvent for every object being deleted from the database. However, debugging the application shows that the FullTextEventListener never receives the PostDeleteEvent. Removing the obects with the Lucene APIs through the IdexWriter work but is inefficient.

The code for creating a PostDeleteEvent follows:
Code:
SessionImpl sessImpl = (SessionImpl) factory.getCurrentSession();
                SessionImplementor implementor = sessImpl.getPersistenceContext().getSession();
                EntityPersister persister = implementor.getEntityPersister("MetadataValue", mv);
                EntityEntry entry = sessImpl.getPersistenceContext().getEntry(mv);
                // sessImpl.getPersistenceContext().setEntryStatus(entry, Status.DELETED);
                Object[] deletedState = new Object[]
                { mv };
                entry.setDeletedState(deletedState);
                PostDeleteEvent pdEvent = new PostDeleteEvent(entry, entry.getId(), deletedState,
                        entry.getPersister(), (EventSource) sessImpl);



Here is the HQL Query:
Quote:
Session session = factory.getCurrentSession();
Query q = session.createQuery("delete from MetadataValue mv where mv.id in (:mvs)");
q.setParameterList("mvs", metaValueIds);
int result = q.executeUpdate();


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.