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