Stackoverflow exception if Composite id has many to one relationship and fetchMode = EAGER

Description

Stackoverflow occurred if composite id has many to one relationshipt.
See unit test in attached file.

Environment

hibernate-core: 3.3.0.SP1, hibernate-annotations: 3.4.0.GA

Activity

Show:
Kirill Trofimov
October 14, 2009, 12:40 PM

The commented line is not solution to resolve the issue,

AmaraG
October 14, 2009, 11:48 AM

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.

Duplicate

Assignee

Unassigned

Reporter

Kirill Trofimov

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major