ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anders Andersen <anders.ander...@cph.dk>
Subject Trim on left side in where clause expressions
Date Mon, 23 Feb 2009 10:43:25 GMT
Hi,

We are trying to use iBATIS/Ibator on a database that is traditionally updated via optimistic
locking.
Doing so we have come across a problem with our where clauses and the code that is generated
by Ibator, because most fields in our database are of type CHAR. In Ibator there is a supported
property called "trimStrings" on the <javaModelGenerator> element, however this only
trim strings
on the right side of the where clause expressions (e.g. WHERE MYFIELD = rtrim('     Hello
 ')) and
we need the left side to be trimmed as well. We can of cause changed the Ibator generated
code
but that would be a manually process that would be overwritten next time we run Ibator.

We have tried to look at the possibilities for extending Ibator via Plug-In's or the like,
but have not
found a good point of entry for this yet. However we have localized the place in the Ibator
code
that we could change to solve this - it is ExampleGenerator.java:

-- snip --
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
 String nameFragment, String operator) {

       ...


        sb.append(introspectedColumn.getAliasedActualColumnName());

        sb.append(' ');

        sb.append(operator);

        sb.append("\", "); //$NON-NLS-1$



        ...
    }
-- snip --

should be changed to

-- snip --
private Method getSingleValueMethod(IntrospectedColumn introspectedColumn,
 String nameFragment, String operator) {
       ...

        sb.append("rtrim(" + introspectedColumn.getAliasedActualColumnName()+ ")");
        sb.append(' ');
        sb.append(operator);
        sb.append("\", "); //$NON-NLS-1$

        ...
    }
-- snip --

Is this possible through a plug-in or otherwise?

Any information that can help us solve this will be highly appreciated!


Venlig hilsen / Kind regards

Anders Andersen

IT Consultant - IT afdelingen / IT department
Copenhagen Airports A/S
Lufthavnsboulevarden 6, DK-2770 Kastrup
Tel./Phone no.: +45 60660306
e-mail: anders.andersen@cph.dk

Mime
View raw message