this is exactly what I was looking for. When I enable this property
Code:
<property name="hibernate.search.worker.execution">async</property>
I get the following error when doing an insert:
Code:
1641 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:derby://localhost:1527/Events;create=true
Exception in thread "pool-3-thread-1" org.apache.lucene.store.AlreadyClosedException: this Directory is closed
at org.apache.lucene.store.Directory.ensureOpen(Directory.java:220)
at org.apache.lucene.store.FSDirectory.list(FSDirectory.java:320)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:533)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:272)
at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:1088)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:686)
at org.hibernate.search.backend.Workspace.getIndexWriter(Workspace.java:180)
at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.performWriterWorks(PerDPQueueProcessor.java:104)
at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.run(PerDPQueueProcessor.java:88)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
my code is very simple and is essentially the following:
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
long startTime = Calendar.getInstance().getTimeInMillis();
session.beginTransaction();
//code to create entity....
Entity e = new Entity();
session.persist(e);
session.getTransaction().commit();
long endCreate = Calendar.getInstance().getTimeInMillis();
System.out.println("Create and Store time " + (endCreate - startTime));
HibernateUtil.getSessionFactory().close();
Any ideas why this is happening?