Jérôme BENOIS's Weblog "MDE 2.0 :)"

Aller au contenu | Aller au menu | Aller à la recherche

mercredi 20 août 2008

Bug Day on Hibernate Module !

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

mercredi 26 mars 2008

JEE-Spring Acceleo Module Screencast

I created four screencast about last enhancements in JEE-Spring Acceleo Module :

  • Here you can discover how to create an empty project based on Maven directory layout. It contains a default UML model with Acceleo Business Profile already applied, and an Ivy configuration file used to define required dependencies.

You must install my IvyDE and JEE Acceleo Module snapshots from this update-site. And you must add ivysettings.xml in your home directory and define reference in Ivy eclipse preferences.

  • Here You can learn how to use JEE-Spring Acceleo Module in order to generate java source code, unit test, spring and hibernate configuration files. This target server platform is based on Spring Framework, Hibernate and the Hessian Remoting protocol.
  • Here How to develop unit tests and fill user code blocks :)