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 WhyDontYouSlide <wh...@gmail.com> on 2008/06/20 21:03:00 UTC

custom type handler

hey guys,

i got serious problems while mapping a Object via a custom typeHandler

I have this resultMap here:

 <resultMap id="CustomObjectResultMap" class="CustomObject">
  	<result property="id" column="ID" />  
  	<result property="name" column="NAME" />  
  	<result property="AnotherObject"
typeHandler="org.it.datatype.CustomTypeHandler" />
 </resultMap>

i i go in a LEFT JOIN on the Table which "map" the "AnotherObject" object.
Problem is when the query (going left on that table) doesnt returns nothing
for that object...
Ibatis cannot recognize it from a LEFT join result so it istantiate the
object in the result map BUT this object contains nothing but nulls in its
properties!
I woudl like he NOT maps at all in this case leaving the object to me
completely null itself!

to do that I was thinking about a AnotherObjectTypeHAndler that implements
TypeHandlerCallBack

the mtehod getResult:

public Object getResult(ResultGetter getter) throws SQLException {
      
       //How here u get the "AnotherObject" from the getter (ResultSet?)
here???

        if (getter.wasNull()) {
            return null; //this is ok for my needs to have the whole object
null in this case!
        }
        AnotherObject obj = ??? //How do I get rid of object here??
        return obj;
    }

while in a simple Boolean typeHandler u can go right due the using of
primitives types..
but u cannot in this case map one Object -> single column at DB.

int value = getter.getInt(); //goes well but its a primitive!

I would like to handle the "AnotherObject" direcly as an "int" ! (so for
speaking..)

Can someone show this to me plz? 

ty

WDYS
-- 
View this message in context: http://www.nabble.com/custom-type-handler-tp18035579p18035579.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.