JSR-352 example

Hi all~

I want to implement reindexing data with the JSR-352 integration.
I read Hibernate Search 6.1.5.Final: Reference Documentation.
But, I can’t get full source code of JSR-352 mass-indexing job example.
Above url shows only part of source code.

I don’t know even full dependency.
When I added following dependency in build.gradle,
implementation 'org.hibernate.search:hibernate-search-mapper-orm-batch-jsr352-jberet'

‘MassIndexingJob’ is not recognized.

Could you recommend full source code of example or reference site?

Thank you.

Hi,

Your link literally lists everything you just asked for. There are two dependencies, both listed there. And there is a snippet of five lines of code that is all you need to start indexing, assuming you already picked and configured a JSR-352 runtime.

I don’t know what you are asking for exactly?

@yrodiere
I meant that
“MassIndexingJob” was not imported in IntelliJ althouth I added the dependency mented in “docs.jboss.org

I mean, the class is definitely there (I just checked the content of the published JAR, in case I was going crazy).

It’s probably a setup problem? Maybe Gradle’s implementation dependencies don’t import transitive dependencies such as hibernate-search-mapper-orm-batch-jsr352-core? I don’t know, I generally use Maven.

@yrodiere
ok. Thanks your reply. Then I will check IntelliJ or gradle setting.

By the way,


 Properties jobProps = MassIndexingJob.parameters()
                                             .forEntities( xx.class )
                                             .build();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        long executionId = jobOperator.start( MassIndexingJob.NAME, jobProps );

just above codes can do reindexing?

There is no transactional action like ‘entityManager’ in that codes. So, I don’t understand how it works.

It retrieves the entity manager itself from the entity manager factory.

There’s some documentation here if you need to select a particular entity manager factory.

1 Like

@yrodiere
one more question!

I resolved import problem.

But, I got following error during runtime after executing code JSR-352 example - #5 by Hello_Hi.

NPE in “jobOperator.start” = “jobOperator” is null

2022-07-29 09:07:42.399 WARN 20723 --- [ Test worker] javax.batch.runtime.BatchRuntime : The ServiceLoader was unable to find an implementation for JobOperator. Check classpath for META-INF/services/javax.batch.operations.JobOperator file.

What should I do?

You should add a JSR-352 runtime. JBeret being one.

But really, if you are not familiar with JSR-352 (and it seems you are not), I would suggest going with the MassIndexer. It doesn’t require any additional dependency, it’s much more battle-tested, and it doesn’t require any additional configuration like JSR-352 runtimes do.

@yrodiere
Thank you for your reply.

Actually, I want to re-index entities about specific condition (not all entities) like ‘yesterday / specific column value’ because re-indexing of all entities takes too much load on ES in case of huge size index.

So I considered JSR-352.

As far as I know, MassIndexer doesn’t support it, Does it?

And can you recommend any guide for me to set JSR-352 runtime?

It does: Hibernate Search 6.1.5.Final: Reference Documentation

I can’t, I don’t have one. To be honest this integration is mainly aimed at people who are already using JSR-352 and want to use it for Hibernate Search as well.

1 Like