Hi All,
I've searched the forum and have come across a few similar posts - they are all close but none of those talk exactly about the issue that I’m having so I figure I should start a new thread.
The issue I'm having is that when I use EAGER loading the indexing works fine but as soon as I change the fetch type to LAZY, which is what I actually want to do, it blows up while creating hibernate indexes.
I have made sure that the method that creates search indexes has an @Transactional annotation on it. I have spent a lot of time looking through different posts and have tried a many different things but it in vain. Any help is much appreciated!!
Code:
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(
name="AssetAddressHistory",
joinColumns=
@JoinColumn(name="uniqueAssetId", referencedColumnName="uniqueAssetId", insertable=false, updatable=false),
inverseJoinColumns=
@JoinColumn(name="addressSequenceNumber", referencedColumnName="addressSequenceNumber", insertable=false, updatable=false))
@WhereJoinTable(clause = "currentAssetLocation = 'Y'")
@NotFound(action=NotFoundAction.IGNORE)
@IndexedEmbedded
protected List<AssetAddress> assetAddress;
Exception:
Code:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: [package_name].assetAddress, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:272)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:436)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:380)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:328)
at org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:317)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.addWorkToBuilderQueue(BatchedQueueingProcessor.java:153)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.processWorkByLayer(BatchedQueueingProcessor.java:140)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:128)
at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.flushWorks(PostTransactionWorkQueueSynchronization.java:69)
at org.hibernate.search.backend.impl.TransactionalWorker.flushWorks(TransactionalWorker.java:78)
at org.hibernate.search.impl.FullTextSessionImpl.flushToIndexes(FullTextSessionImpl.java:98)
...
Regards
Abrar