Skip to content

www.rolfje.com

Tag: ibatis

Ibatis Inline Parameter Maps

Posted on 2010-02-16 By rolfje 3 Comments on Ibatis Inline Parameter Maps

Today I (re)discovered a feature in the Ibatis data mapper framework which was clearly documented, but for some reason was not being used in our project. The feature is called “inline parameter maps” and combined with a wrapper bean it can clean up a lot of clutter in the code and in the SqlMaps. Please feel free to share this example with your fellow Ibatis Data Mapper 2 framework users.

Read More “Ibatis Inline Parameter Maps” »

Uncategorized

Ibatis 2.2 Ignores XML encoding

Posted on 2008-07-20 By rolfje No Comments on Ibatis 2.2 Ignores XML encoding

At my company, we’re using Ibatis to do operations on Oracle databases. As most of our software is designed to be international, we keep our XML files in UTF-8 encoding. Recently we discovered that Ibatis had some trouble parsing the XML files when we were using diacritics in them. As it turns out, Ibatis 2.2 actually ignores the “UTF-8” setting in the XML file header altogether.

This was actually reported as an issue at apache’s issue tracker, and fixed in Ibatis release 2.3 and upward. In the meantime, if you can not swich to a new release because of tight deadlines and no time for regression tests, you can set the file.encoding property to UTF-8, because then Ibatis will parse the XML in the correct encoding.

Uncategorized

Ibatis Nullpointer calling stored procedure

Posted on 2006-11-07 By rolfje 1 Comment on Ibatis Nullpointer calling stored procedure
Today, a collegue of mine had a really strange nullpointer problem trying to call a stored procedure in an Oracle 10 database using iBATIS Java 2.2.0. What she had was a normal JavaBean, like so: 

package com.rolfje.foo
public class BarBean {
    private String barName;
    private Long barId;

    ... setters/getters here ...
}

A straightforward parametermap:

<parameterMap class="com.rolfje.foo.BarBean"
      id="barbeanMap">
   <parameter property="barName" />
   <parameter property="barId" />
</parameterMap>

and a straightforward procedure mapping:

<procedure id="insertBar" parameterMap="barbeanMap">
   {	call store_bar (
      ?,?)
   }
</procedure>

When trying to call the stored procedure, she got the following stacktrace:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL [];
SQL state [null]; error code [0];
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException; nested exception is

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
   at ...executeQueryWithCallback(GeneralStatement.java:188)
   at ...executeQueryForObject(GeneralStatement.java:104)
   at ...queryForObject(SqlMapExecutorDelegate.java:565)
...

After hours of staring at the problem, and comparing code with similar constructions from other projects, we decided to switch to the Oracle 9i thin driver to see if that would solve the problem. It didn’t, but there was an interesting development: The Oracle 9i driver actually gave us a decent error about not being able to parse the SQL statement. Which brings us to…

The solution:
We removed all layout from the procedure mapping, which resulted in:

<procedure id="insertBar" parameterMap="barbeanMap">
   {call store_bar (?,?)}
</procedure>

This solved the problem. Then we switched back to the Oracle 10i thin driver, and the problem was still gone. The problem lies in the TAB between the left curly bracket and the word “call”. Oracle can not handle this.To investigate this problem, we then also tried to insert <![CDATA[ ]]> around the procedure call, but as soon as there is a TAB between the { and the word “call” iBATIS will throw a NullPointer. The strange thing is that you can have spaces, newlines and tabs *anywhere* in the procedure mapping, as long as there is no TAB between the left curly and the word “call”.

Software
           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme