[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4436) Stackoverflow exception if Composite id has many to one relationship and fetchMode = EAGER

D.M.A. Gunawardana (JIRA) noreply at atlassian.com
Wed Oct 14 05:48:43 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34186#action_34186 ] 

D.M.A. Gunawardana commented on HHH-4436:
-----------------------------------------

Hi,

If you happens to comment out session.evict() from the test it gets passed.

public void testBug() throws Exception {
        Session session = sessionFactory.openSession();
        try {
            ClassA classA;
            Transaction transaction = session.beginTransaction();
            transaction.begin();
            try {
                classA = new ClassA();
                List<ClassB> children = new ArrayList<ClassB>();

                ClassB classB = new ClassB();
                ClassBPK pk = new ClassBPK();
                pk.setClassA(classA);
                pk.setName(UUID.randomUUID().toString());
                classB.setClassBPK(pk);

                children.add(classB);
                classA.setChildren(children);

                session.persist(classA);
            } catch (Exception e) {
                transaction.rollback();
                throw e;
            }
            transaction.commit();
            
            session.evict(classA);// commenting out this lines makes the test passed.
            

            session.get(ClassA.class, classA.getId());
        } catch (Exception e) {
            session.close();
            throw e;
        }
    }

As per the documentation of evict() method, it will remove the associated object from the session cache. So in your next line session.get(ClassA.class, classA.getId()) you are trying to get an object from session which is already removed from session.

> Stackoverflow exception if Composite id has many to one relationship and fetchMode = EAGER
> ------------------------------------------------------------------------------------------
>
>                 Key: HHH-4436
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4436
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.0.SP1
>         Environment: hibernate-core: 3.3.0.SP1, hibernate-annotations: 3.4.0.GA
>            Reporter: Kirill Trofimov
>         Attachments: hibernatetest.zip
>
>
> Stackoverflow occurred if composite id has many to one relationshipt.
> See unit test in attached file.

-- 
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