This morning, i tracked strange bug on the Acceleo Hibernate module :
__________________ ______________________
| CLASS_MANY_01_BI |<-- * {-} 1 -->| CLASS_MANY_01_BI_END |
|__________________| |______________________|
The generator created this bloc in Class_Many_01_BI_END.hbm.xml :
<set name="source" inverse="true">
<key column="FK__TARGET_ID"/>
<one-to-many class="org.acceleo.hibernate.bug.entities.Class_Many_01_BI"/>
</set>
But the correct mapping seems to be :
<set name="source" inverse="true">
<key column="FK_CLASS_MANY_01_BI_END_TARGET_ID"/>
<one-to-many class="org.acceleo.hibernate.bug.entities.Class_Many_01_BI"/>
</set>
I wrote a basic unit test to detect the problem :
@Test public void testMany_01_BI() throws Exception{
Class_Many_01_BI_END target = new Class_Many_01_BI_END();
getSession().save(target);
Class_Many_01_BI source = new Class_Many_01_BI();
source.setTarget(target);
getSession().save(source);
getSession().flush();
getSession().clear();
target = (Class_Many_01_BI_END)getSession().load(Class_Many_01_BI_END.class, target.getId());
assertNotNull(target);
assertNotNull(target.getSource());
assertEquals("Bad mapping detected!", 1, target.getSource().size());
}
And after short debate on #acceleo IRC channel, thanks Gougou, i added my fix on trunk here :
svn diff -r1655:1656 svn://svn.forge.objectweb.org/svnroot/acceleo/trunk/modules/community/uml21/jee/trunk
This problem gives me to think how to improve this module. The
"org.acceleo.module.pim.uml21.gen.jee.tests" non-regression plan is a good
point to guarantee stability and the module consistency. Indeed, it's good
tools but i think we could add a unit test suite to check all uses cases
defines by the non-regression plan. And, we could detect others problems like
my bug of the day 