ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francois LE ROLLAND" <f.leroll...@ortems.com>
Subject Abator tool extension
Date Tue, 23 Jan 2007 14:33:42 GMT
Hi,

 

            I'm wondering if it could be possible to add the column names as constant in the
generated Java Model. I've tried something like that 

In the class JavaModelGeneratorJava2Impl and it works fine for me :

 

        // FLD

        Field constant;

        Method method;

 

        while (columnDefinitions.hasNext()) {

            ColumnDefinition cd = (ColumnDefinition) columnDefinitions.next();

            FullyQualifiedJavaType fqjt = cd.getResolvedJavaType()

                    .getFullyQualifiedJavaType();

 

            topLevelClass.addImportedType(fqjt);

 

            String property = cd.getJavaProperty();

 

            field = new Field();

            field.addComment(table, cd.getColumnName());

            field.setVisibility(JavaVisibility.PRIVATE);

            field.setType(fqjt);

            field.setName(property);

            topLevelClass.addField(field);

            

            // FLD - begin

            constant = new Field();

            constant.addComment(table, cd.getColumnName());

            constant.setVisibility(JavaVisibility.PUBLIC);

            constant.setModifierFinal(true);

            constant.setModifierStatic(true);

            constant.setType(FullyQualifiedJavaType.getStringInstance());

            constant.setName(cd.getColumnName());

            constant.setInitializationString("\""+property+"\"");

            topLevelClass.addField(constant);            

            // FLD - end

            ...

 

This is very usefull when you handle the domain classes from within binding solutions like
"JGoodies bindings" to reference bean properties.

 

Thanks

 

Fran├žois Le Rolland

 

 


Mime
View raw message