emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

TypeHandlerRegistry does not get a handler for Class type: java.math.BigInt and JdbcType: BIGINT #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
MyBatis version: 3.0.2

I am trying to load associations with multiple keys:
eg: <association property="attribute" select="selectAttributes" 
column="{itemId=id, langCode=lang_code}" />

Where the id column is a BIGINT and the lang_code column is a VARCHAR.

The column="{itemId=id, langCode=lang_code}" should give me a HashMap with both 
parameters.
The langCode turns into a String correctly and the itemId is turned into a 
java.math BigInteger.

During the process the UnkownTypeHandler is invoked and tries to resolve the 
java.math.BigInteger/BIGINT combination. The method 
UnknownTypeHanlder.resolveTypeHandler(Onject parameter, JdbcType jdbcType) 
returns null which causes the calling method 
UnknownTypeHanlder.setNonNullParameter to throw a NullPointer at line 27 where 
it tries to use the returned handler without checking if its NULL.

Maybe I am doing something wrong or I am missing something, pointers greatly 
appreciated!

I hope this was clear enough, if you have anymore questions please don't 
hesitate to contact me!

Original issue reported on code.google.com by christ...@binaryworx.net on 30 Sep 2010 at 11:29

GoogleCodeExporter commented 9 years ago
Due to the nature of our project I implemented and gegistered a bespoke type 
handler for BigInteger classes which fixes the issue for me. 
I still think as mybatis instantiates the BigInteger objects for the hashmap it 
should also have a type handler for them :)

In my custom type handler I currently convert BigInteger to Long...

Original comment by christ...@binaryworx.net on 30 Sep 2010 at 12:30

GoogleCodeExporter commented 9 years ago
Would you mind posting your type handler for us.  I can try to squeeze this 
into the next release.

Original comment by nathan.m...@gmail.com on 18 Nov 2010 at 4:04

GoogleCodeExporter commented 9 years ago
Hi Nathan,

you might have to check if this is done properly :) It works, but I might have 
overlooked something.

Cheers,
Christian

Original comment by christ...@binaryworx.net on 18 Nov 2010 at 4:13

Attachments:

GoogleCodeExporter commented 9 years ago
I believe this is now fixed.  Please give it a try and feel free to reopen if 
you find an issue.

Original comment by jeffgbut...@gmail.com on 29 Dec 2010 at 9:19

GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 4 Apr 2012 at 10:39