Thank a lot! I have implemented a plugin like this and it solved our issue :-)
Btw, funny to note the SVN log on that new plugin example ;-) plugins$ svn log CaseInsensitiveLikePlugin.java ------------------------------------------------------------------------ r747134 | jgbutler | 2009-02-23 21:58:13 +0100 (Mon, 23 Feb 2009) | 1 line [Ibator] New example plugin for case insensitive LIKE searches ------------------------------------------------------------------------ Venlig hilsen / Kind regards Anders Andersen IT Consultant - IT afdelingen / IT department Københavns Lufthavne A/S Lufthavnsboulevarden 6, DK-2770 Kastrup Tel./Phone no.: +45 60660306 e-mail: [email protected] ________________________________________ From: Jeff Butler [[email protected]] Sent: Monday, February 23, 2009 10:54 PM To: [email protected] Subject: Re: Trim on left side in where clause expressions This is possible in a couple of ways - you could do it with a plugin, or by extending the generated example classes. With a plugin, the basic idea is to add methods to the example's inner Criteria class to deal with the RTRIM function (and LTRIM too???). I was going to explain how, but an example is better. See here: http://svn.apache.org/repos/asf/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java This plugin adds case insensitive LIKE expressions to the generated example class. You could use it as a model for developing your own plugin. The Ibator documentation includes a page on extending the example classes that shows how to accomplish this by extension. If you have a lot of CHAR fields that you want to use, then the plugin would be better. Hope that helps - Jeff Butler On Mon, Feb 23, 2009 at 4:43 AM, Anders Andersen <[email protected]> wrote: > 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: [email protected] >
