[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4436?page=c...
]
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira