ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tracey Annison" <tanni...@trisystems.co.uk>
Subject RE: Problem with using generic and specific custom TypeHandlers
Date Mon, 15 May 2006 10:45:24 GMT
I found some references to it being hard to map a java.lang.Boolean,
dues to confusion with the primitive type boolean. No solution that
works, but some references to it being a problem...

So, as an experiment, I tried doing the same thing with a special Java
enum mapping to an AS/400 String, rather than a Boolean mapping to a
string. I deliberately used a TypeHandler that already worked fine when
used in a generic way, and that fails completely with null pointer
exceptions all over the place! Saying "Check the
XXX-InlineParameterMap", "Check the parameter mapping for the 'xxx'
property.", and so on...  

Does applying a specific TypeHandler to a particular field in a
resultMap and parameterMap just not work at all? How on earth can anyone
set up mappings to databases with varying code values for a Boolean or
enum without this ability?
Is there ANY information about this available? Or any manuals for this
product? 'cos now I'm completely stuck, and so is our project...

Cheers
Tracey Annison

-----Original Message-----
From: Tracey Annison [mailto:tannison@trisystems.co.uk] 
Sent: 15 May 2006 08:32
To: user-java@ibatis.apache.org
Subject: RE: Problem with using generic and specific custom TypeHandlers

Well, initially I didn't have the <typeHandlers>, just the individual
<typeHandler> elements in there. But was advised to add that
<typeHandlers> in. But it makes absoluteloy no difference anyway - the
generic TypeHandlerStringANYEnum defined in there works fine with or
without it!

But the specific TypeHandlerStringYNBoolean that I want to make work on
just one field doesn't even get called...

Cheers
Tracey Annison

-----Original Message-----
From: Niels Beekman [mailto:n.beekman@wis.nl]
Sent: 15 May 2006 08:32
To: user-java@ibatis.apache.org
Subject: RE: Problem with using generic and specific custom TypeHandlers

Are you using the DTD for your sqlmap configfile? There is no such
element "typeHandlers"...

Niels

-----Original Message-----
From: Tracey Annison [mailto:tannison@trisystems.co.uk]
Sent: maandag 15 mei 2006 9:20
To: user-java@ibatis.apache.org
Subject: RE: Problem with using generic and specific custom TypeHandlers

Thanks, Ben. 

Well, I now have XML like this : 

Generic TypeHandler in the sql-map-config.xml-
===================================
<typeHandlers>
	<typeHandler javaType="uk.co.package.user_type.FlagANY"
callback="uk.co.package.utils.TypeHandlerStringANYEnum"/>
</typeHandlers>
===================================


And in the thing.xml I have a ResultMap and ParameterMap like this -
===================================
<resultMap id="thingResult"
class="uk.co.package.persistence.ThingIbatis">
        <result column="OCFRED" property="fred"/>
        <result column="OCBILL" property="bill"
typeHandler="uk.co.package.utils.TypeHandlerStringYNBoolean"/>
</resultMap>

<parameterMap id="thingResult"
class="uk.co.package.persistence.ThingIbatis">
        <parameter  property="fred"/>
        <parameter property="bill"
typeHandler="uk.co.package.utils.TypeHandlerStringYNBoolean"/>
/parameterMap>
===================================


And I have Java code like this for ThingIbatis -
===================================
import uk.co.package.user_type.FlagANY;

public class ThingIbatis implements Comparable<ThingIbatis> {

    private FlagANY fred = FlagANY.N;
    private Boolean bill = FlagYN.getDefaultBoolean();


    public FlagANY getFred() {
        return this.fred;
    }

    public Boolean getBill() {
        return this.bill;
    }

    public void setFred(FlagANY fred) {
        this.fred = fred;
    }

    public void setBill(Boolean bill) {
        this.bill = bill;
    }
}
===================================

And I'm still not getting the specific TypeHandler called. The
TypeHandlerStringANYEnum works fine for fred, but the
TypeHandlerStringYNBoolean is never invoked for bill.


I can't see what else I ought to be doing...

Cheers
Tracey Annison




----------------------------------------------------------------------
The information in this email is confidential and may be legally
privileged. 
It is intended solely for the addressee. Access to this email by anyone
else is unauthorised. If you are not the intended recipient, any
disclosure, copying, distribution, or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful. 
TriSystems Ltd. cannot accept liability for statements made which are
clearly the sender's own.





----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged. 
It is intended solely for the addressee. Access to this email by 
anyone else is unauthorised. If you are not the intended recipient, 
any disclosure, copying, distribution, or any action taken or omitted 
to be taken in reliance on it, is prohibited and may be unlawful. 
TriSystems Ltd. cannot accept liability for statements made which are clearly
the sender's own.



Mime
View raw message