Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

SQL Map Generator by Alex Egorov

Alex has created some handy scripts to generate all of your SQL Maps and configuration. If you're looking to jumpstart your development with iBATIS, this is a good tool to try. The website is a bit slow, but it's a lot faster than coding by hand. (wink)

Attempting to save changes to this page resulted in an error: Not saving page 3rd Party Contributions because content matches blacklist: nar0d.ru. So, I changed the link to use TinyURL. I also had to replace the o with a 0 to produce nar0d so that I could include the error message...sheesh!

Wiki Markup
\[^http://tinyurl.com/4fks8\]

Jasmine IDE IBatis GUI

Well I've taken a crack at a point and click program for building maps/ value objects and a dao class (not ibatis dao just a java class to invoke an sqlclient's methods). It allows you to set up a project and specify a db connection along with all the usual config stuff. (You need to set up your db connections first. Make sure that your driver and all jars are on the system classpath)

It shows all the tables in your selected connection which you use to build your objects and maps by pointing and clicking. Create a new Value object and double click a table and then double click columns. It's a bit like ms access query builder with the addition of fields for java type, java name etc.. It also writes the config file and updates the map references as you create new maps. Also a util class with a single static method which creates the Reader and reads the config and returns the SQLMapsClient. You can daisy chain maps together by adding list (called "Complex properties" on the UI) properties to your java value object and specifying the map to fetch them.

I've used it on 2 small projects so far and it seems to save a lot of work. There are a few pain in the neck things that I need to sort out but it works ok. Mainly it always rewrites all 3 files when you reopen you value object in the GUI. So if you've tweaked them your changes get overwritten. If you bear that in mind it seems fairly useful. Once you get everything set up you just tweak things outside the UI. Sorry there is no documentation at all.

Maybe this thing will actually help somebody out.

It's included in JasmineIDE as a plugin.

Wiki Markup
\[^http://sourceforge.net/projects/jasmineide\]
\[^http://jasmineide.sourceforge.net\]

Convert ResultSet to JSTL Result

Wiki Markup
This was posted to \[^http://dir.gmane.org/gmane.comp.java.ibatisdb.user ibatis-user-java\], but I thought it might be convenient to dump it here as well:

ResultSetToResultHandler.java

Here's a simple config (it's also an example of using an Oracle cursor as an OUT parameter for a stored procedure):

No Format
<sqlMapConfig>

    <typeAlias alias="result"
               type="javax.servlet.jsp.jstl.sql.Result"/>

    <typeAlias alias="cursorHandler"
               type="com.dotech.ibatis.ResultSetToResultHandler"/>

    <typeHandler javaType="result"
                 jdbcType="ORACLECURSOR"
                 callback="cursorHandler"/>
</sqlMapConfig>
No Format
<sqlMap>

    <parameterMap id="noInputsSingleResult" class="map">
        <parameter property="resultCode"
                   javaType="int"
                   jdbcType="NUMERIC"
                   nullValue="-1"
                   mode="OUT"/>
        <parameter property="result"
                   javaType="result"
                   jdbcType="ORACLECURSOR"
                   mode="OUT"/>
    </parameterMap>

    <procedure id="getFunds" parameterMap="noInputsSingleResult">
        {?= call get_funds(?)}
    </procedure>

</sqlMap>
No Format
SqlMapExecutor exec = ...;
Map params = new HashMap(2);
exec.queryForObject("getFunds", params);
Integer resultCode = (Integer)params.get("resultCode");
if (resultCode == null) {
    // error
} else {
    int resultCodeValue = resultCode.intValue();
    if (resultCodeValue == 0) {
        Result result = (Result)params.get("result");
        // process
    } else {
        // error
    }
}

Wiki Markup
Although this solution relies on JSTL (\[^http://java.sun.com/products/jsp/jstl/index.jsp JSP Standard Tag Library\]) classes, it is not limited to Servlet/JSP or J2EE applications, nor does it require the use of other JSTL features. The {{javax.servlet.jsp.jstl.sql.Result}} interface (\[^http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jstl/sql/Result.html API\]) and the {{javax.servlet.jsp.jstl.sql.ResultSupport}} class (\[^http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jstl/sql/ResultSupport.html API\]) only depend on J2SE. In other words, this solution will work for pretty much any Java application.

Wiki Markup
An implementation of JSTL is provided by Apache's \[^http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html Jakarta Standard Taglib project\]. Please note that if you do want to use the other features of JSTL in a web application, the provided link is for a version of the Standard taglib that is compatible with JSP 2.0. A version that is compatible with JSP 1.2 can be found \[^http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/intro.html here\]. No matter which version you choose, the classes will be located in the {{jstl.jar}} file that is included in the distribution.