-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with purge(Class entityType, Serializable id)
PostPosted: Thu May 03, 2012 5:20 am 
Newbie

Joined: Thu May 03, 2012 4:55 am
Posts: 3
Hi All !
I am trying to force reindex single entity with following code:
Code:
    public int fullTextSearchReindex(final PK primaryKey) {
        int result = 0;
        if (null != getPersistentClass().getAnnotation(org.hibernate.search.annotations.Indexed.class)) {
            sessionFactory.evict(getPersistentClass(), primaryKey);
            T entity = findById(primaryKey);
            FullTextSession fullTextSession = Search.getFullTextSession(sessionFactory.getCurrentSession());
            fullTextSession.setFlushMode(FlushMode.MANUAL);
            fullTextSession.setCacheMode(CacheMode.IGNORE);
            fullTextSession.purge(getPersistentClass(), primaryKey);
            fullTextSession.flushToIndexes(); //apply changes to indexes
            if (entity != null && isIncludeInLuceneIndex(entity)) {
                fullTextSession.index(HibernateHelper.unproxy(entity));
                result++;
            }
            fullTextSession.flushToIndexes(); //apply changes to indexes
            fullTextSession.clear(); //clear since the queue is processed
        }
        return result;
    }



and get error at
fullTextSession.purge(getPersistentClass(), primaryKey);
fullTextSession.flushToIndexes();
Stack trace , provided below, whats wrong ?

Code:
java.lang.IllegalStateException: Could not get property value
   at org.hibernate.search.util.impl.ReflectionHelper.getMemberValue(ReflectionHelper.java:94)
   at org.hibernate.search.engine.spi.AbstractDocumentBuilder.appendContainedInWorkForInstance(AbstractDocumentBuilder.java:265)
   at org.hibernate.search.engine.impl.WorkPlan$PerEntityWork.processContainedIn(WorkPlan.java:525)
   at org.hibernate.search.engine.impl.WorkPlan$PerClassWork.processContainedInAndPrepareExecution(WorkPlan.java:297)
   at org.hibernate.search.engine.impl.WorkPlan.processContainedInAndPrepareExecution(WorkPlan.java:144)
   at org.hibernate.search.backend.impl.WorkQueue.prepareWorkPlan(WorkQueue.java:135)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:71)
   at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.flushWorks(PostTransactionWorkQueueSynchronization.java:124)
   at org.hibernate.search.backend.impl.TransactionalWorker.flushWorks(TransactionalWorker.java:179)
   at org.hibernate.search.impl.FullTextSessionImpl.flushToIndexes(FullTextSessionImpl.java:136)
   at org.yes.cart.dao.impl.GenericDAOHibernateImpl.fullTextSearchReindex(GenericDAOHibernateImpl.java:372)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy29.fullTextSearchReindex(Unknown Source)
   at org.yes.cart.dao.impl.ProductDAOTest.testCreateNewProductTest(ProductDAOTest.java:376)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
   at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
   at org.junit.rules.RunRules.evaluate(RunRules.java:18)
   at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
   at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
   at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
Caused by: java.lang.IllegalArgumentException: Invoking attribute on a  null object
   at org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:81)
   at org.hibernate.search.util.impl.ReflectionHelper.getMemberValue(ReflectionHelper.java:91)
   ... 46 more
Caused by: java.lang.NullPointerException
   at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.hibernate.annotations.common.reflection.java.JavaXProperty.invoke(JavaXProperty.java:74)
   ... 47 more


Top
 Profile  
 
 Post subject: Re: Problem with purge(Class entityType, Serializable id)
PostPosted: Thu May 03, 2012 9:00 am 
Hibernate Team
Hibernate Team

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

I am not sure exactly what the problem is without the getting more context (annotated classes and the context of the code you are showing). That said, there is no need to purge the index if you are going to update it right afterwards. (Re-)Indexing an entity will always replace an existing index document.

--Hardy


Top
 Profile  
 
 Post subject: Re: Problem with purge(Class entityType, Serializable id)
PostPosted: Fri May 04, 2012 7:07 am 
Newbie

Joined: Thu May 03, 2012 4:55 am
Posts: 3
hardy.ferentschik wrote:
(Re-)Indexing an entity will always replace an existing index document.

--Hardy


Thanks for advice, now it works as expected


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