ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Maves" <nathan.ma...@gmail.com>
Subject Re: using typeHandler
Date Wed, 28 Feb 2007 15:21:32 GMT
IMHO this is a bad way or trying to reduce code.

Let me point out a few reasons :)

1.  Why use a map if you are only ever going to pass 1 string in.  That is
twice the amount of memory needed to object creation.

2.  You have moved database specific information into your java code.  I
think it is a good practice to have all sql in the maps.  I think it is much
more readable and easier to debug.  You java code will be littered with
map.get("SOME_COLUMN") calls.  Not clean in my opinion.

3.  As long as you keep the static table name string in your DAO layer you
should not run into SQL injection but I get scared every time I see the $$.

4.  Some one might correct me but I believe that using actual result classes
with result maps is more performant then always using maps.

Sorry to be so negative,  I just woke up :)

On 2/28/07, Stefano Mancini <smancini@idoq.it> wrote:
> Hi,
> I've the following problem:
> I want to read the rows of a generic table into a List of HashMaps using a
> statement like this one
> <select id="selectAll" remapResults="true" resultClass="java.util.HashMap"
> parameterClass="java.util.Map">
>     select * from $table$
> </select>
> If the table contains a column of type BLOB in the resulting map is
> inserted an object of type oracle.sql.BLOB (I'm using oracle 10g), I would
> like to have a byte[] in this case. I've inserted the following mapping
> <typeHandler jdbcType="BLOB" javaType = "[B" callback="
> com.ibatis.sqlmap.engine.type.BlobTypeHandlerCallback" />
> in the SqlMap with no results (I've used "[B] as javaType because byte[]
> isn't accepted).
> Obviously if I use a resultMap with all the properties specified all works
> fine, but it's no more general.
> Any ideas ?

View raw message