You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Geek Cracovian <ge...@gmail.com> on 2010/04/25 22:56:24 UTC

Extended support for primitive type mapping

Hi All,

I'd like to suggest a little patch for iBATIS 'trunk' which improves
handling of primitive types.
I had a similar problem to these issues:
http://www.mail-archive.com/user-java@ibatis.apache.org/msg11096.html
http://www.mail-archive.com/user-java@ibatis.apache.org/msg07181.html	

I need to define a type alias for byte array:
<typeAlias type="[B" alias="bytes" />

Since iBATIS is using ClassLoader#loadClass method for loading classes,
the primitive class names are not being understood which results in
ClassNotFoundException. With the following patch iBATIS will use
Class#loadClass(String,boolean,ClassLoader) method. Using this fix,
mapping of byte arrays works fine for me.

Best regards,
Geek Cracovian


The patch:

Index: src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java
===================================================================
--- src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java
(revision 937818)
+++ src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java  (working
copy)
@@ -188,7 +188,7 @@

         try {

-          Class c = cl.loadClass(name);
+          Class c = Class.forName(name, true, cl);

           if (null != c) return c;

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Extended support for primitive type mapping

Posted by Geek Cracovian <ge...@gmail.com>.
Thanks!

On 2010-04-26 03:50, Clinton Begin wrote:
> Done.  I've also added type aliases for array versions of all of the
> built in types (using the same naming convention for primitives), for
> example:
> 
> "byte[]" ==> Byte[].class
> 
> "_byte[]" ==> byte[].class
> 
> etc.
> 
> Cheers,
> Clinton
> 
> On Sun, Apr 25, 2010 at 2:56 PM, Geek Cracovian
> <geek.cracovian@gmail.com <ma...@gmail.com>> wrote:
> 
>     Hi All,
> 
>     I'd like to suggest a little patch for iBATIS 'trunk' which improves
>     handling of primitive types.
>     I had a similar problem to these issues:
>     http://www.mail-archive.com/user-java@ibatis.apache.org/msg11096.html
>     http://www.mail-archive.com/user-java@ibatis.apache.org/msg07181.html
> 
>     I need to define a type alias for byte array:
>     <typeAlias type="[B" alias="bytes" />
> 
>     Since iBATIS is using ClassLoader#loadClass method for loading classes,
>     the primitive class names are not being understood which results in
>     ClassNotFoundException. With the following patch iBATIS will use
>     Class#loadClass(String,boolean,ClassLoader) method. Using this fix,
>     mapping of byte arrays works fine for me.
> 
>     Best regards,
>     Geek Cracovian
> 
> 
>     The patch:
> 
>     Index: src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java
>     ===================================================================
>     --- src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java
>     (revision 937818)
>     +++ src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java  (working
>     copy)
>     @@ -188,7 +188,7 @@
> 
>             try {
> 
>     -          Class c = cl.loadClass(name);
>     +          Class c = Class.forName(name, true, cl);
> 
>               if (null != c) return c;
> 
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>     <ma...@ibatis.apache.org>
>     For additional commands, e-mail: user-java-help@ibatis.apache.org
>     <ma...@ibatis.apache.org>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Extended support for primitive type mapping

Posted by Clinton Begin <cl...@gmail.com>.
Done.  I've also added type aliases for array versions of all of the built
in types (using the same naming convention for primitives), for example:

"byte[]" ==> Byte[].class

"_byte[]" ==> byte[].class

etc.

Cheers,
Clinton

On Sun, Apr 25, 2010 at 2:56 PM, Geek Cracovian <ge...@gmail.com>wrote:

> Hi All,
>
> I'd like to suggest a little patch for iBATIS 'trunk' which improves
> handling of primitive types.
> I had a similar problem to these issues:
> http://www.mail-archive.com/user-java@ibatis.apache.org/msg11096.html
> http://www.mail-archive.com/user-java@ibatis.apache.org/msg07181.html
>
> I need to define a type alias for byte array:
> <typeAlias type="[B" alias="bytes" />
>
> Since iBATIS is using ClassLoader#loadClass method for loading classes,
> the primitive class names are not being understood which results in
> ClassNotFoundException. With the following patch iBATIS will use
> Class#loadClass(String,boolean,ClassLoader) method. Using this fix,
> mapping of byte arrays works fine for me.
>
> Best regards,
> Geek Cracovian
>
>
> The patch:
>
> Index: src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java
> ===================================================================
> --- src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java
> (revision 937818)
> +++ src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java  (working
> copy)
> @@ -188,7 +188,7 @@
>
>         try {
>
> -          Class c = cl.loadClass(name);
> +          Class c = Class.forName(name, true, cl);
>
>           if (null != c) return c;
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>