I have managed to fail the code I have already submitted to JIRA. Three small changes required. If necessary, I can pack another archive and open new issue. Or may be after a quick look you will say "this isn't a bug - you did something wrong".
1. fixing ProjectOrganization hashCode to avoid initializing Organization proxy:
Code:
return (organization == null) ? 0 : organization.getId().hashCode();
2. add one more Organization to the database:
Code:
insert into organization (organization_id, name) values (101, 'org2');
3. Modify the test itself to attempt to add this Organization into Projects's collection of organizations:
Code:
Project project = (Project) session.load(Project.class, new Long(1));
Organization org = (Organization) session.load(Organization.class, new Long(101));
ProjectOrganization po = new ProjectOrganization();
po.setWeight(5);
po.setOrganization(org);
Set set = project.getProjectOrganizations();
set.add(po);
session.flush();
Run and get:
Hibernate: select project0_.PROJECT_ID as PROJECT_ID0_, project0_.NAME as NAME0_ from PROJECT project0_ where project0_.PROJECT_ID=?
Hibernate: select project_0_.weight as weight__, project_0_.ORGANIZATION_ID as ORGANIZA3___, project_0_.PROJECT_ID as PROJECT_ID__ from PROJECT_ORGANIZATION project_0_ where project_0_.PROJECT_ID=?
Hibernate: select workingt1_.WORKING_TIME_SET_ID as WORKING_TIME_SET_ID0_, organiza0_.ORGANIZATION_ID as ORGANIZATION_ID1_, organiza0_.NAME as NAME1_, organiza0_.WORKING_TIME_SET_ID as WORKING_3_1_ from ORGANIZATION organiza0_, WORKING_TIME_SET workingt1_ where organiza0_.ORGANIZATION_ID=? and organiza0_.WORKING_TIME_SET_ID=workingt1_.WORKING_TIME_SET_ID(+)
Hibernate: select workingt1_.WORKING_TIME_SET_ID as WORKING_TIME_SET_ID0_, organiza0_.ORGANIZATION_ID as ORGANIZATION_ID1_, organiza0_.NAME as NAME1_, organiza0_.WORKING_TIME_SET_ID as WORKING_3_1_ from ORGANIZATION organiza0_, WORKING_TIME_SET workingt1_ where organiza0_.ORGANIZATION_ID=? and organiza0_.WORKING_TIME_SET_ID=workingt1_.WORKING_TIME_SET_ID(+)
Hibernate: select working_0_.WORKING_TIME_START as WORKING_2___, working_0_.WORKING_TIME_END as WORKING_3___, working_0_.IS_WORKING_DAY as IS_WORKI4___, working_0_.WORKING_TIME_SET_ID as WORKING_1___, working_0_.WEEK_DAY as WEEK_DAY__ from WORKING_TIME working_0_ where working_0_.WORKING_TIME_SET_ID=?
[ERROR] AssertionFailure - -An AssertionFailure occured - this may indicate a bug in Hibernate <net.sf.hibernate.AssertionFailure: Hibernate has a bug processing collections>net.sf.hibernate.AssertionFailure: Hibernate has a bug processing collections
at net.sf.hibernate.impl.SessionImpl$CollectionEntry.postFlush(SessionImpl.java:319)
at net.sf.hibernate.impl.SessionImpl.postFlush(SessionImpl.java:2737)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at Test.main(Test.java:60)
net.sf.hibernate.AssertionFailure: Hibernate has a bug processing collections
at net.sf.hibernate.impl.SessionImpl$CollectionEntry.postFlush(SessionImpl.java:319)
at net.sf.hibernate.impl.SessionImpl.postFlush(SessionImpl.java:2737)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at Test.main(Test.java:60)
Exception in thread "main" Process terminated with exit code 1
Code: