[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HSEARCH-460) LazyInitializationException while removing entity with @ContainedIn annotation

Maciej Szulik (JIRA) noreply at atlassian.com
Thu Apr 8 03:06:44 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36243#action_36243 ] 

Maciej Szulik edited comment on HSEARCH-460 at 4/8/10 2:05 AM:
---------------------------------------------------------------

I've tried you proposition and I'm afraid that didn't do the trick.
The problem is with session management and how hibernate search access objects in session.
It can be handled by adding proxy objects initialization like this:
{code}
Color colorToRemove = em.merge(color);
Hibernate.initialize(colorToRemove.getRzeczy());
em.remove(colorToRemove);
{code}
But above solution is unacceptable from my point of view, mainly because one server bean controls over a hundred different dictionary objects, which contains different objects' collections.

      was (Author: soltys):
    I've tried you proposition and I'm afraid that didn't do the trick.
The problem is with session management and how hibernate search access objects in session.
It can be handled by adding proxy objects initialization like this:
{code}
Color colorToRemove = em.merge(color);
Hibernate.initialize(colorToRemove.getRzeczy());
em.remove(colorToRemove);
{code}
But above solution is unacceptable from my point of view!
  
> LazyInitializationException while removing entity with @ContainedIn annotation
> ------------------------------------------------------------------------------
>
>                 Key: HSEARCH-460
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-460
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 3.1.1.GA
>            Reporter: Maciej Szulik
>         Attachments: hibsearch.zip, Lazy.stack
>
>
> I attach a Jboss Seam 2.2.0.GA project (without lib directory - one should take it entirely from seam default application generated using seam gen), as a complete illustration of the problem.
> The Problem itself:
> I have 2 entities:
> Color (Long id, String name, Set<Vehicle> vehicles) 
> and Vehicle (Long id, String name, Color color).
> Vehicle is indexed entity (@Indexed), while color has @ContainedIn on Set<Vehicle>.
> Problem arises while managing color objects, strictly speaking while removing colors, LazyInitalizationException is thrown (stack trace is in attachment).
> Every other operation on color entity (inserting, updating) works like a charm. 
> In attached example I created with a simple page for managing colors. It presents a list of already defined color objects in DB. If non present, you should generate some with 'Add random color'. To obtain above error click on 'Remove' link next to one of the colors presented on list.

-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list