[
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-689?pag...
]
Bayo Erinle commented on HSEARCH-689:
-------------------------------------
Sanne - Below is a script you can use to seed the database to get the result
insert into z_leg_car(car_id, model) values('1', 'model1');
insert into z_leg_car(car_id, model) values('2', 'model2');
insert into z_leg_car(car_id, model) values('3', 'model3');
insert into z_leg_car_plant(car_id,plant_id,plant_name)
values('1','2','plant12');
As for the stacktrace, yes it is related to Hibernate Search version 3.3.0.Final.
Thanks.
MassIndexer throwing LazyInitializationException on associated
collections
--------------------------------------------------------------------------
Key: HSEARCH-689
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-689
Project: Hibernate Search
Issue Type: Bug
Components: massindexer
Affects Versions: 3.3.0.Final
Environment: Hibernate 3.6.0.Final
Oracle Database 11g Release 11.1.0.0.0 - Production and HSQLDB 1.8.0
Unix/Windows XP
Reporter: Bayo Erinle
Assignee: Sanne Grinovero
Priority: Blocker
Fix For: 3.4.0
Attachments: hs_forum_poc.zip
The root element I am indexing LegacyCarPlant has a reference to LegacyCar, which in turn
embeds a collection of LegacyTire.
When I kick off the indexer, I always get a LazyInitializationException on the
collections.
(PS: See stack trace at the tail end)
If I make them eager, then the issue goes away, but ideally, I don't want to fetch
them eagerly. I'll much rather prefer they remain lazily fetched for obvious reasons.
The alternative is to crawl through in a loop and index using fullTextSession.index(T),
but that is really really slow as I have upwards of 3million records and still growing.
I have read the forums and tried all the suggestions I have seen including trying to run
it on a single thread like
fullTextSession.createIndexer(LegacyCarPlant.class)
.batchSizeToLoadObjects(30)
.threadsForSubsequentFetching(1)
.threadsToLoadObjects(1)
to no avail.
Also, I have tried with the snapshot of 3.4.0 and the same error exists.
If I do make the root element LegacyPlant, then I don't get the error as well. In my
situation though, I need to have LegacyCarPlant be the root.
The test program is "legacy_index_run.groovy"
Stack Trace:
04:34:30 DEBUG SQL.logStatement - select count(*) as y0_ from Z_LEG_CAR_PLANT this_
04:34:30 INFO SimpleIndexingProgressMonitor.addToTotalCount - Going to reindex 1
entities
04:34:30 DEBUG SQL.logStatement - select this_.CAR_ID as y0_, this_.PLANT_ID as y1_ from
Z_LEG_CAR_PLANT this_
04:34:30 DEBUG SQL.logStatement - select this_.CAR_ID as CAR1_2_1_, this_.PLANT_ID as
PLANT2_2_1_, this_.PLANT_NAME as PLANT3_2_1_, legacycar2_.CAR_ID as CAR1_0_0_,
legacycar2_.MODEL as MODEL0_0_ from Z_LEG_CAR_PLANT this_ left outer join Z_LEG_CAR
legacycar2_ on this_.CAR_ID=legacycar2_.CAR_ID where (this_.CAR_ID, this_.PLANT_ID) in
((?, ?))
04:34:30 ERROR LazyInitializationException.<init> - failed to lazily initialize a
collection of role: com.jrock.forum.LegacyCar.tires, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of
role: com.jrock.forum.LegacyCar.tires, no session or session was closed
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
at
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
at
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:457)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:481)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:379)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:317)
at
org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.index(EntityConsumerLuceneworkProducer.java:155)
at
org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.indexAllQueue(EntityConsumerLuceneworkProducer.java:123)
at
org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.run(EntityConsumerLuceneworkProducer.java:96)
at
org.hibernate.search.batchindexing.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:107)
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:680)
04:34:30 ERROR EntityConsumerLuceneworkProducer.run - error during batch indexing:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of
role: com.jrock.forum.LegacyCar.tires, no session or session was closed
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
at
org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
at
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
at
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:457)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:481)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:379)
at
org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:317)
at
org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.index(EntityConsumerLuceneworkProducer.java:155)
at
org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.indexAllQueue(EntityConsumerLuceneworkProducer.java:123)
at
org.hibernate.search.batchindexing.EntityConsumerLuceneworkProducer.run(EntityConsumerLuceneworkProducer.java:96)
at
org.hibernate.search.batchindexing.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:107)
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:680)
04:34:30 INFO SimpleIndexingProgressMonitor.indexingCompleted - Reindexed 1 entities
done indexing! Total time taken: 893 ms
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira