ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <Larry.Mead...@plumcreek.com>
Subject Re: A few dumb questions
Date Tue, 30 Nov 2004 00:07:16 GMT
>>> oliver.zeigermann@gmail.com 11/29/04 2:53 PM >>>
> I see, what is the benefit over using pure SQL, JDBC or something like
> http://jakarta.apache.org/commons/dbutils/index.html then?

I have not used dbUtils, but I just took a quick look at the examples
page:
 - http://jakarta.apache.org/commons/dbutils/examples.html

Here are some major differences I see:

 - The amount of code you have to write is much smaller with iBATIS. For
example, the ResultSetHandler class that is shown on the dbUtils page is
really always done for you in the sql maps.

 - The sql in the first example there is also extracted from your java
code. Which would you rather read:

<mapped-statement name="getUnit" result-class="java.util.HashMap"
cache-model="five-minute">
    select
        unt as "unit",
        dsc as "description"
    from
        RMUnt
    where
        unt = #unit#
</mapped-statement>

 - or - 

String mySQL = "select unt as \"unit\", "
 + "dsc as \"description\" "
 + "from RMUnt "
 + "where unt = ?";

(...add more code here to move the columns into a map entries, deal with
caching, deal with empty resultsets, SQL exceptions and so on...)

Also, because your sql is external to your java code, you can use
dialect specific sql very easily (by using a properties file to specify
the path to the sql maps).

Larry


Mime
View raw message