ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject Re: Inherited getter and inline parameter map => NullPointerException
Date Thu, 15 May 2008 21:52:08 GMT
Generics should work fine.  I haven't read this whole thread about the
inheritance yet, but generics such as this should work without problems, as
long as PK is a simple type, *OR*, you create a custom type handler for
whatever you're using for the PK.

   public interface BaseDomain<PK extends Serializable>
   {
     public PK getCodigo();
   }


To Java, in this case, PK will basically always be a Serializable as far as
the reflection API is concerned.  So all you need to do is be explicit when
defining your map to this property.

<parameter property="codigo" javaType="string" .../>
....
<result property="codigo" javaType="string" .../>

Etc.

As for the problem this thread describes, I suggest writing that unit test
you were talking about so that we can better understand the problem and
debug it if necessary.

Cheers,
Clinton

On Thu, May 15, 2008 at 2:38 PM, Thiago F. G. Albuquerque <tfga@mpdft.gov.br>
wrote:

> But... why? Is this a design decision? Are there any plans to support
> generics in the future?
>
> Thiago
>
> Jeff Butler wrote:
>
>> Ahhh...this is far beyond the introspection capability of iBATIS.  iBATIS
>> is built for JDK 1.4 and will not understand these types of getters.
>>  Jeff Butler
>>
>> On Thu, May 15, 2008 at 2:11 PM, Thiago F. G. Albuquerque <
>> tfga@mpdft.gov.br <mailto:tfga@mpdft.gov.br>> wrote:
>>
>>    Jeff Butler wrote:
>>
>>        OK - we need to see the SQL map (just the update) and the two
>>        Java classes.  Hopefully they are not too big :)
>>
>>
>>    I'm afraid they are :-/ And to make matters worse, all the
>>    indentifiers are in Portuguese.
>>    I can write some minimal code that reproduces the problem and send
>>    it to the list.
>>
>>    But, I was thinking... maybe the problem is not the inheritance. In
>>    fact, all the getters in this class are inherited. What is different
>>    about this getter in particular is that its return type in the
>>    superinterface is generic:
>>
>>    public interface BaseDomain<PK extends Serializable>
>>    {
>>      public PK getCodigo();
>>    }
>>
>>    ("codigo"(pt) == "code"(en)).
>>
>>    Thiago
>>
>
>

Mime
View raw message