Indexing failed on not loaded collection of entities and breaks transaction with LazyInitializationException










0















I load an entity in my UI, change several things and update my entity with a new transaction, but Hibernate Search intercept within my transaction and try to update search index. That would be find, except it tries to load an collection that is annotated with @IndexedEmbedded() that was not used and so will throw an LazyInitializationException.



How I can prevent this?



Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (before transaction completion) 
at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:173)
at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:954)
at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:525)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2480)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:98)
... 76 common frames omitted
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.foo.Bar, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:597)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:216)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:576)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:147)
at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:188)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:553)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:593)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:402)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:299)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:241)
at org.hibernate.search.engine.impl.WorkPlan$PerEntityWork.enqueueLuceneWork(WorkPlan.java:560)
at org.hibernate.search.engine.impl.WorkPlan$PerClassWork.enqueueLuceneWork(WorkPlan.java:322)
at org.hibernate.search.engine.impl.WorkPlan.getPlannedLuceneWork(WorkPlan.java:188)
at org.hibernate.search.backend.impl.WorkQueue.prepareWorkPlan(WorkQueue.java:115)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:55)
at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.beforeCompletion(PostTransactionWorkQueueSynchronization.java:67)
at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:170)
... 84 common frames omitted









share|improve this question


























    0















    I load an entity in my UI, change several things and update my entity with a new transaction, but Hibernate Search intercept within my transaction and try to update search index. That would be find, except it tries to load an collection that is annotated with @IndexedEmbedded() that was not used and so will throw an LazyInitializationException.



    How I can prevent this?



    Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (before transaction completion) 
    at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:173)
    at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:954)
    at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:525)
    at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2480)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
    at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:98)
    ... 76 common frames omitted
    Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.foo.Bar, could not initialize proxy - no Session
    at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:597)
    at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:216)
    at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:576)
    at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:147)
    at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:188)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:553)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:593)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:402)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:299)
    at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:241)
    at org.hibernate.search.engine.impl.WorkPlan$PerEntityWork.enqueueLuceneWork(WorkPlan.java:560)
    at org.hibernate.search.engine.impl.WorkPlan$PerClassWork.enqueueLuceneWork(WorkPlan.java:322)
    at org.hibernate.search.engine.impl.WorkPlan.getPlannedLuceneWork(WorkPlan.java:188)
    at org.hibernate.search.backend.impl.WorkQueue.prepareWorkPlan(WorkQueue.java:115)
    at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:55)
    at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.beforeCompletion(PostTransactionWorkQueueSynchronization.java:67)
    at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:170)
    ... 84 common frames omitted









    share|improve this question
























      0












      0








      0








      I load an entity in my UI, change several things and update my entity with a new transaction, but Hibernate Search intercept within my transaction and try to update search index. That would be find, except it tries to load an collection that is annotated with @IndexedEmbedded() that was not used and so will throw an LazyInitializationException.



      How I can prevent this?



      Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (before transaction completion) 
      at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:173)
      at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:954)
      at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:525)
      at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2480)
      at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
      at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:98)
      ... 76 common frames omitted
      Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.foo.Bar, could not initialize proxy - no Session
      at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:597)
      at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:216)
      at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:576)
      at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:147)
      at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:188)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:553)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:593)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:402)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:299)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:241)
      at org.hibernate.search.engine.impl.WorkPlan$PerEntityWork.enqueueLuceneWork(WorkPlan.java:560)
      at org.hibernate.search.engine.impl.WorkPlan$PerClassWork.enqueueLuceneWork(WorkPlan.java:322)
      at org.hibernate.search.engine.impl.WorkPlan.getPlannedLuceneWork(WorkPlan.java:188)
      at org.hibernate.search.backend.impl.WorkQueue.prepareWorkPlan(WorkQueue.java:115)
      at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:55)
      at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.beforeCompletion(PostTransactionWorkQueueSynchronization.java:67)
      at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:170)
      ... 84 common frames omitted









      share|improve this question














      I load an entity in my UI, change several things and update my entity with a new transaction, but Hibernate Search intercept within my transaction and try to update search index. That would be find, except it tries to load an collection that is annotated with @IndexedEmbedded() that was not used and so will throw an LazyInitializationException.



      How I can prevent this?



      Caused by: org.hibernate.HibernateException: Error while indexing in Hibernate Search (before transaction completion) 
      at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:173)
      at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:954)
      at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:525)
      at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2480)
      at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:473)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:178)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:39)
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:271)
      at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:98)
      ... 76 common frames omitted
      Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.foo.Bar, could not initialize proxy - no Session
      at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:597)
      at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:216)
      at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:576)
      at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:147)
      at org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:188)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:553)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFieldsForEmbeddedObjects(DocumentBuilderIndexedEntity.java:593)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:482)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:402)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:299)
      at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.addWorkToQueue(DocumentBuilderIndexedEntity.java:241)
      at org.hibernate.search.engine.impl.WorkPlan$PerEntityWork.enqueueLuceneWork(WorkPlan.java:560)
      at org.hibernate.search.engine.impl.WorkPlan$PerClassWork.enqueueLuceneWork(WorkPlan.java:322)
      at org.hibernate.search.engine.impl.WorkPlan.getPlannedLuceneWork(WorkPlan.java:188)
      at org.hibernate.search.backend.impl.WorkQueue.prepareWorkPlan(WorkQueue.java:115)
      at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:55)
      at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.beforeCompletion(PostTransactionWorkQueueSynchronization.java:67)
      at org.hibernate.search.event.impl.EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(EventSourceTransactionContext.java:170)
      ... 84 common frames omitted






      hibernate hibernate-search






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 15:01









      zeitigerzeitiger

      8718




      8718






















          1 Answer
          1






          active

          oldest

          votes


















          0














          When this happens, it generally means you closed the session that was used to load the entity, and tried to update the entity using another session.
          It happens in some frameworks where you need to serialize the entities between the loading and the actual update, for some reason.



          The easiest solution is: don't detach and use entities across different sessions, it'll just bring you headaches. And I'm not talking about just Hibernate Search.



          If you really want to do it, it's possible, but not as obvious as it might first seem.



          There are ways to avoid using detached entities in Wicket, at least. For other frameworks, without knowing more about your UI framework, I can't really help. I doubt I can help if it's a UI framework I don't know, but it's worth a shot ;)



          If you decide to provide more information, please at least mention: the Hibernate ORM and Hibernate Search versions you're using, and the exact code you use when interacting with the Session/EntityManager (.persist(), .merge(), .saveOrUpdate(), ...), and the UI code related to storing/transferring the entity between components.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322250%2findexing-failed-on-not-loaded-collection-of-entities-and-breaks-transaction-with%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            When this happens, it generally means you closed the session that was used to load the entity, and tried to update the entity using another session.
            It happens in some frameworks where you need to serialize the entities between the loading and the actual update, for some reason.



            The easiest solution is: don't detach and use entities across different sessions, it'll just bring you headaches. And I'm not talking about just Hibernate Search.



            If you really want to do it, it's possible, but not as obvious as it might first seem.



            There are ways to avoid using detached entities in Wicket, at least. For other frameworks, without knowing more about your UI framework, I can't really help. I doubt I can help if it's a UI framework I don't know, but it's worth a shot ;)



            If you decide to provide more information, please at least mention: the Hibernate ORM and Hibernate Search versions you're using, and the exact code you use when interacting with the Session/EntityManager (.persist(), .merge(), .saveOrUpdate(), ...), and the UI code related to storing/transferring the entity between components.






            share|improve this answer



























              0














              When this happens, it generally means you closed the session that was used to load the entity, and tried to update the entity using another session.
              It happens in some frameworks where you need to serialize the entities between the loading and the actual update, for some reason.



              The easiest solution is: don't detach and use entities across different sessions, it'll just bring you headaches. And I'm not talking about just Hibernate Search.



              If you really want to do it, it's possible, but not as obvious as it might first seem.



              There are ways to avoid using detached entities in Wicket, at least. For other frameworks, without knowing more about your UI framework, I can't really help. I doubt I can help if it's a UI framework I don't know, but it's worth a shot ;)



              If you decide to provide more information, please at least mention: the Hibernate ORM and Hibernate Search versions you're using, and the exact code you use when interacting with the Session/EntityManager (.persist(), .merge(), .saveOrUpdate(), ...), and the UI code related to storing/transferring the entity between components.






              share|improve this answer

























                0












                0








                0







                When this happens, it generally means you closed the session that was used to load the entity, and tried to update the entity using another session.
                It happens in some frameworks where you need to serialize the entities between the loading and the actual update, for some reason.



                The easiest solution is: don't detach and use entities across different sessions, it'll just bring you headaches. And I'm not talking about just Hibernate Search.



                If you really want to do it, it's possible, but not as obvious as it might first seem.



                There are ways to avoid using detached entities in Wicket, at least. For other frameworks, without knowing more about your UI framework, I can't really help. I doubt I can help if it's a UI framework I don't know, but it's worth a shot ;)



                If you decide to provide more information, please at least mention: the Hibernate ORM and Hibernate Search versions you're using, and the exact code you use when interacting with the Session/EntityManager (.persist(), .merge(), .saveOrUpdate(), ...), and the UI code related to storing/transferring the entity between components.






                share|improve this answer













                When this happens, it generally means you closed the session that was used to load the entity, and tried to update the entity using another session.
                It happens in some frameworks where you need to serialize the entities between the loading and the actual update, for some reason.



                The easiest solution is: don't detach and use entities across different sessions, it'll just bring you headaches. And I'm not talking about just Hibernate Search.



                If you really want to do it, it's possible, but not as obvious as it might first seem.



                There are ways to avoid using detached entities in Wicket, at least. For other frameworks, without knowing more about your UI framework, I can't really help. I doubt I can help if it's a UI framework I don't know, but it's worth a shot ;)



                If you decide to provide more information, please at least mention: the Hibernate ORM and Hibernate Search versions you're using, and the exact code you use when interacting with the Session/EntityManager (.persist(), .merge(), .saveOrUpdate(), ...), and the UI code related to storing/transferring the entity between components.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 7:33









                yrodiereyrodiere

                2,7811315




                2,7811315





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322250%2findexing-failed-on-not-loaded-collection-of-entities-and-breaks-transaction-with%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    27

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    Category:Rhetoric