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 "Thiago F. G. Albuquerque" <tf...@mpdft.gov.br> on 2008/05/14 21:40:58 UTC

Inherited getter and inline parameter map => NullPointerException

Hi,

When I have a inherited getter in the domain object and the corresponding attribute appears in an inline parameter map, I get a NullPointerException:

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in Evento.abator.sqlmap.xml.  
--- The error occurred while applying a parameter map.  
--- Check the Evento.abatorgenerated_updateByPrimaryKey-InlineParameterMap.  
--- Check the parameter mapping for the 'codigo' property.  
--- Cause: java.lang.NullPointerException
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
	at org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:384)
	at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
	... 56 more
Caused by: java.lang.NullPointerException
	at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
	at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
	at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
	... 60 more

Here is BasicParameterMap.java:165:

    // Set Parameter
    TypeHandler typeHandler = mapping.getTypeHandler();
    if (value != null) {
=>    typeHandler.setParameter(ps, i + 1, value, mapping.getJdbcTypeName()); // <= typeHandler == null !
    } else if (typeHandler instanceof CustomTypeHandler) {
      typeHandler.setParameter(ps, i + 1, value, mapping.getJdbcTypeName());
    } else {

When I overwrite the getter in the subclass, the error disappears. Maybe iBatis can't get the return type of inherited methods and, as a result, can't resolve the type handler?

Regards,
Thiago


Re: Inherited getter and inline parameter map => NullPointerException

Posted by Jeff Butler <je...@gmail.com>.
Clinton is right,  I tried this with many different varieties of generic
interface and it worked for me every time.

So we need your test case that reproduces the problem.

Jeff Butler



On Thu, May 15, 2008 at 4:52 PM, Clinton Begin <cl...@gmail.com>
wrote:

> 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 <ma...@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
>>>
>>
>>
>

Re: Inherited getter and inline parameter map => NullPointerException

Posted by Jeff Butler <je...@gmail.com>.
As to why, it is because there is a large install base of iBATIS users and
we have committed that the iBATIS 2.x releases will run with JDK 1.4.

As for the future, look here:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard
Jeff Butler


On Thu, May 15, 2008 at 3:38 PM, Thiago F. G. Albuquerque <tf...@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 <ma...@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
>>
>
>

Re: Inherited getter and inline parameter map => NullPointerException

Posted by Clinton Begin <cl...@gmail.com>.
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 <tf...@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 <ma...@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
>>
>
>

Re: Inherited getter and inline parameter map => NullPointerException

Posted by "Thiago F. G. Albuquerque" <tf...@mpdft.gov.br>.
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 <ma...@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


Re: Inherited getter and inline parameter map => NullPointerException

Posted by Jeff Butler <je...@gmail.com>.
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 <tf...@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
>
> Jeff Butler
>>
>> On Wed, May 14, 2008 at 3:46 PM, Thiago F. G. Albuquerque <
>> tfga@mpdft.gov.br <ma...@mpdft.gov.br>> wrote:
>>
>>    Version 2.3.0.677.
>>
>>    Jeff Butler wrote:
>>
>>        What version of iBATIS are you using?  I have tests with this
>>        exect scenario working now.
>>         Jeff Butler
>>
>>        On Wed, May 14, 2008 at 2:40 PM, Thiago F. G. Albuquerque
>>        <tfga@mpdft.gov.br <ma...@mpdft.gov.br>
>>         <mailto:tfga@mpdft.gov.br <ma...@mpdft.gov.br>>> wrote:
>>
>>           Hi,
>>
>>           When I have a inherited getter in the domain object and the
>>           corresponding attribute appears in an inline parameter map, I
>>        get a
>>           NullPointerException:
>>
>>           Caused by:
>>        com.ibatis.common.jdbc.exception.NestedSQLException:      ---
>>        The error occurred in Evento.abator.sqlmap.xml.  --- The error
>>           occurred while applying a parameter map.  --- Check the
>>           Evento.abatorgenerated_updateByPrimaryKey-InlineParameterMap.
>>         ---
>>           Check the parameter mapping for the 'codigo' property.  ---
>>        Cause:
>>           java.lang.NullPointerException
>>                  at
>>
>> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
>>                  at
>>
>> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
>>                  at
>>
>> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
>>                  at
>>
>> org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:384)
>>                  at
>>
>> org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
>>                  ... 56 more
>>           Caused by: java.lang.NullPointerException
>>                  at
>>
>> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
>>                  at
>>
>> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
>>                  at
>>
>> com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
>>                  at
>>
>> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
>>                  at
>>
>> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
>>                  ... 60 more
>>
>>           Here is BasicParameterMap.java:165:
>>
>>             // Set Parameter
>>             TypeHandler typeHandler = mapping.getTypeHandler();
>>             if (value != null) {
>>           =>    typeHandler.setParameter(ps, i + 1, value,
>>           mapping.getJdbcTypeName()); // <= typeHandler == null !
>>             } else if (typeHandler instanceof CustomTypeHandler) {
>>               typeHandler.setParameter(ps, i + 1, value,
>>           mapping.getJdbcTypeName());
>>             } else {
>>
>>           When I overwrite the getter in the subclass, the error
>>        disappears.
>>           Maybe iBatis can't get the return type of inherited methods
>>        and, as
>>           a result, can't resolve the type handler?
>>
>>           Regards,
>>           Thiago
>>
>>
>>
>>
>>
>

Re: Inherited getter and inline parameter map => NullPointerException

Posted by "Thiago F. G. Albuquerque" <tf...@mpdft.gov.br>.
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

> Jeff Butler
> 
> On Wed, May 14, 2008 at 3:46 PM, Thiago F. G. Albuquerque 
> <tfga@mpdft.gov.br <ma...@mpdft.gov.br>> wrote:
> 
>     Version 2.3.0.677.
> 
>     Jeff Butler wrote:
> 
>         What version of iBATIS are you using?  I have tests with this
>         exect scenario working now.
>          Jeff Butler
> 
>         On Wed, May 14, 2008 at 2:40 PM, Thiago F. G. Albuquerque
>         <tfga@mpdft.gov.br <ma...@mpdft.gov.br>
>         <mailto:tfga@mpdft.gov.br <ma...@mpdft.gov.br>>> wrote:
> 
>            Hi,
> 
>            When I have a inherited getter in the domain object and the
>            corresponding attribute appears in an inline parameter map, I
>         get a
>            NullPointerException:
> 
>            Caused by:
>         com.ibatis.common.jdbc.exception.NestedSQLException:      ---
>         The error occurred in Evento.abator.sqlmap.xml.  --- The error
>            occurred while applying a parameter map.  --- Check the
>            Evento.abatorgenerated_updateByPrimaryKey-InlineParameterMap.
>          ---
>            Check the parameter mapping for the 'codigo' property.  ---
>         Cause:
>            java.lang.NullPointerException
>                   at
>          
>          com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
>                   at
>          
>          com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
>                   at
>          
>          com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
>                   at
>          
>          org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:384)
>                   at
>          
>          org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
>                   ... 56 more
>            Caused by: java.lang.NullPointerException
>                   at
>          
>          com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
>                   at
>          
>          com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
>                   at
>          
>          com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
>                   at
>          
>          com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
>                   at
>          
>          com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
>                   ... 60 more
> 
>            Here is BasicParameterMap.java:165:
> 
>              // Set Parameter
>              TypeHandler typeHandler = mapping.getTypeHandler();
>              if (value != null) {
>            =>    typeHandler.setParameter(ps, i + 1, value,
>            mapping.getJdbcTypeName()); // <= typeHandler == null !
>              } else if (typeHandler instanceof CustomTypeHandler) {
>                typeHandler.setParameter(ps, i + 1, value,
>            mapping.getJdbcTypeName());
>              } else {
> 
>            When I overwrite the getter in the subclass, the error
>         disappears.
>            Maybe iBatis can't get the return type of inherited methods
>         and, as
>            a result, can't resolve the type handler?
> 
>            Regards,
>            Thiago
> 
> 
> 
> 


Re: Inherited getter and inline parameter map => NullPointerException

Posted by Jeff Butler <je...@gmail.com>.
OK - we need to see the SQL map (just the update) and the two Java classes.
Hopefully they are not too big :)

Jeff Butler

On Wed, May 14, 2008 at 3:46 PM, Thiago F. G. Albuquerque <tf...@mpdft.gov.br>
wrote:

> Version 2.3.0.677.
>
> Jeff Butler wrote:
>
>> What version of iBATIS are you using?  I have tests with this exect
>> scenario working now.
>>  Jeff Butler
>>
>>  On Wed, May 14, 2008 at 2:40 PM, Thiago F. G. Albuquerque <
>> tfga@mpdft.gov.br <ma...@mpdft.gov.br>> wrote:
>>
>>    Hi,
>>
>>    When I have a inherited getter in the domain object and the
>>    corresponding attribute appears in an inline parameter map, I get a
>>    NullPointerException:
>>
>>    Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
>>  --- The error occurred in Evento.abator.sqlmap.xml.  --- The error
>>    occurred while applying a parameter map.  --- Check the
>>    Evento.abatorgenerated_updateByPrimaryKey-InlineParameterMap.  ---
>>    Check the parameter mapping for the 'codigo' property.  --- Cause:
>>    java.lang.NullPointerException
>>           at
>>
>>  com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
>>           at
>>
>>  com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
>>           at
>>
>>  com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
>>           at
>>
>>  org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:384)
>>           at
>>
>>  org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
>>           ... 56 more
>>    Caused by: java.lang.NullPointerException
>>           at
>>
>>  com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
>>           at
>>
>>  com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
>>           at
>>
>>  com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
>>           at
>>
>>  com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
>>           at
>>
>>  com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
>>           ... 60 more
>>
>>    Here is BasicParameterMap.java:165:
>>
>>      // Set Parameter
>>      TypeHandler typeHandler = mapping.getTypeHandler();
>>      if (value != null) {
>>    =>    typeHandler.setParameter(ps, i + 1, value,
>>    mapping.getJdbcTypeName()); // <= typeHandler == null !
>>      } else if (typeHandler instanceof CustomTypeHandler) {
>>        typeHandler.setParameter(ps, i + 1, value,
>>    mapping.getJdbcTypeName());
>>      } else {
>>
>>    When I overwrite the getter in the subclass, the error disappears.
>>    Maybe iBatis can't get the return type of inherited methods and, as
>>    a result, can't resolve the type handler?
>>
>>    Regards,
>>    Thiago
>>
>>
>>
>

Re: Inherited getter and inline parameter map => NullPointerException

Posted by "Thiago F. G. Albuquerque" <tf...@mpdft.gov.br>.
Version 2.3.0.677.

Jeff Butler wrote:
> What version of iBATIS are you using?  I have tests with this exect 
> scenario working now.
>  
> Jeff Butler
> 
> On Wed, May 14, 2008 at 2:40 PM, Thiago F. G. Albuquerque 
> <tfga@mpdft.gov.br <ma...@mpdft.gov.br>> wrote:
> 
>     Hi,
> 
>     When I have a inherited getter in the domain object and the
>     corresponding attribute appears in an inline parameter map, I get a
>     NullPointerException:
> 
>     Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:  
>     --- The error occurred in Evento.abator.sqlmap.xml.  --- The error
>     occurred while applying a parameter map.  --- Check the
>     Evento.abatorgenerated_updateByPrimaryKey-InlineParameterMap.  ---
>     Check the parameter mapping for the 'codigo' property.  --- Cause:
>     java.lang.NullPointerException
>            at
>     com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
>            at
>     com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
>            at
>     com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
>            at
>     org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:384)
>            at
>     org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
>            ... 56 more
>     Caused by: java.lang.NullPointerException
>            at
>     com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
>            at
>     com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
>            at
>     com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
>            at
>     com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
>            at
>     com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
>            ... 60 more
> 
>     Here is BasicParameterMap.java:165:
> 
>       // Set Parameter
>       TypeHandler typeHandler = mapping.getTypeHandler();
>       if (value != null) {
>     =>    typeHandler.setParameter(ps, i + 1, value,
>     mapping.getJdbcTypeName()); // <= typeHandler == null !
>       } else if (typeHandler instanceof CustomTypeHandler) {
>         typeHandler.setParameter(ps, i + 1, value,
>     mapping.getJdbcTypeName());
>       } else {
> 
>     When I overwrite the getter in the subclass, the error disappears.
>     Maybe iBatis can't get the return type of inherited methods and, as
>     a result, can't resolve the type handler?
> 
>     Regards,
>     Thiago
> 
> 


Re: Inherited getter and inline parameter map => NullPointerException

Posted by Jeff Butler <je...@gmail.com>.
What version of iBATIS are you using?  I have tests with this exect scenario
working now.

Jeff Butler

On Wed, May 14, 2008 at 2:40 PM, Thiago F. G. Albuquerque <tf...@mpdft.gov.br>
wrote:

> Hi,
>
> When I have a inherited getter in the domain object and the corresponding
> attribute appears in an inline parameter map, I get a NullPointerException:
>
> Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   --- The
> error occurred in Evento.abator.sqlmap.xml.  --- The error occurred while
> applying a parameter map.  --- Check the
> Evento.abatorgenerated_updateByPrimaryKey-InlineParameterMap.  --- Check the
> parameter mapping for the 'codigo' property.  --- Cause:
> java.lang.NullPointerException
>        at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:94)
>        at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:505)
>        at
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
>        at
> org.springframework.orm.ibatis.SqlMapClientTemplate$10.doInSqlMapClient(SqlMapClientTemplate.java:384)
>        at
> org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
>        ... 56 more
> Caused by: java.lang.NullPointerException
>        at
> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
>        at
> com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
>        at
> com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:79)
>        at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteUpdate(GeneralStatement.java:200)
>        at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:78)
>        ... 60 more
>
> Here is BasicParameterMap.java:165:
>
>   // Set Parameter
>   TypeHandler typeHandler = mapping.getTypeHandler();
>   if (value != null) {
> =>    typeHandler.setParameter(ps, i + 1, value,
> mapping.getJdbcTypeName()); // <= typeHandler == null !
>   } else if (typeHandler instanceof CustomTypeHandler) {
>     typeHandler.setParameter(ps, i + 1, value, mapping.getJdbcTypeName());
>   } else {
>
> When I overwrite the getter in the subclass, the error disappears. Maybe
> iBatis can't get the return type of inherited methods and, as a result,
> can't resolve the type handler?
>
> Regards,
> Thiago
>
>

RE: Exhausted resultset exception when use Oracle REF cursor type as output parameter from Stored Procedure

Posted by Jesse Reimann <jr...@ctigroup.com>.
I've previously been told when I was asking about Oracle REF Cursors
that I should be using "update" instead of "queryForList". Technically
"queryForList" doesn't fully work correctly with REF Cursors since the
return list isn't being populated even though the map passed into
"queryForList" does seem to get populated.

Maybe you can give try switching to using "update" and see if the
problems still arise.

Thanks,

Jesse


-----Original Message-----
From: Eugene Dvorkin [mailto:Eugene.Dvorkin@artstor.org] 
Sent: Friday, May 16, 2008 10:30 AM
To: user-java@ibatis.apache.org
Subject: Exhausted resultset exception when use Oracle REF cursor type
as output parameter from Stored Procedure

Hi,
We developed application with Spring, Hibernate and Ibatis. 
We use Oracle Application Server and configured database Connection Pool
provided by Application Server.
Then we start stress test our application and discovered problem that
appears only under load and only in a call to 
Stored Procedures than returns REF Cursor. 
Caused by: 
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in org/artstor/pojo/CategoryThumbnail.xml.  
--- The error occurred while applying a result map.  
--- Check the CategoryThumbnail.result.  
--- Check the result mapping for the 'thumbnailImgUrl' property.  
--- Cause: java.sql.SQLException: Exhausted Resultset
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:185)

when we use plain select statement, it works fine. The way we call
stored procedures is:
<parameterMap id="searchCategoryParameters" class="map">
	<parameter property="o" javaType="java.sql.ResultSet"
jdbcType="ORACLECURSOR" mode="OUT" resultMap="searchResult" />
	<parameter property="keywords" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" resultMap="searchResult"/>
	<parameter property="objTypeId" jdbcType="NUMBER" javaType="int"
mode="IN" resultMap="searchResult"/>
	<parameter property="orderBy" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" resultMap="searchResult"/>
	<parameter property="outLength" jdbcType="NUMBER" javaType="int"
mode="IN" resultMap="searchResult"/>
	<parameter property="categoryId" jdbcType="NUMBER"
javaType="long" mode="IN" resultMap="searchResult"/>
	<parameter property="thumbnailOnly" jdbcType="NUMBER"
javaType="int" mode="IN" resultMap="searchResult"/>
	<parameter property="start_pos_in" jdbcType="NUMBER"
javaType="int" mode="IN" resultMap="searchResult"/>
	<parameter property="page_length_in" jdbcType="NUMBER"
javaType="int" mode="IN" resultMap="searchResult"/>  
</parameterMap>


<procedure id="searchAllCollection " parameterMap="searchParameters">
{?=call pkg_object_adv_search_new.do_search_v3
(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}
</procedure>

In java :
HashMap<Object, Object> parameters = new HashMap<Object, Object>();
SqlMapClientTemplate client = getSqlMapClientTemplate();
.
.

		client.queryForList("searchAllCollections ",
parameters);
		result = (List) parameters.get("o");

Stored Procedure declaration:
FUNCTION search_collections (
    keyword_words_in    IN   VARCHAR2,
    obj_type_id_in      IN   NUMBER,
    order_by_in         IN   VARCHAR2 DEFAULT ' sco1 desc, sco2 desc',
    outlength_in        IN   NUMBER DEFAULT 501,
    collection_ids_in   IN   VARCHAR2,
    thumbnail_only_in   IN   BOOLEAN
  )
    RETURN pkg_object_search_cursor.return_cur;

Where return type is
TYPE object_cur IS REF CURSOR

When we accessing result from stored procedure, we got problem.
Please help
Sincerely,
eugene


RE: Exhausted resultset exception when use Oracle REF cursor type as output parameter from Stored Procedure

Posted by Eugene Dvorkin <Eu...@artstor.org>.
I think we have all parameters map actually. I just cut some to make
post a little shorter.

the code is working fine, but only up to 30 or so users doing stress
testing. 

 

 

From: BalaKishore Pamarti [mailto:bpamarti@yahoo.com] 
Sent: Friday, May 16, 2008 12:21 PM
To: user-java@ibatis.apache.org
Subject: Re: Exhausted resultset exception when use Oracle REF cursor
type as output parameter from Stored Procedure

 

At the first glance I noticed these --

 

You dont have to sepicify resultMap for all the IN parameters in
parameterMap element.

 

Your listed parameters in the parameterMap element are 9 and your ?'s in
the procedure call are 14. think this should be 8

There is not match for ur parameters specified in the stored procedure
to those in parameterMap element.

 

post the right code.

Eugene Dvorkin <Eu...@artstor.org> wrote:

	Hi,
	We developed application with Spring, Hibernate and Ibatis. 
	We use Oracle Application Server and configured database
Connection Pool
	provided by Application Server.
	Then we start stress test our application and discovered problem
that
	appears only under load and only in a call to 
	Stored Procedures than returns REF Cursor. 
	Caused by: 
	com.ibatis.common.jdbc.exception.NestedSQLException: 
	--- The error occurred in
org/artstor/pojo/CategoryThumbnail.xml. 
	--- The error occurred while applying a result map. 
	--- Check the CategoryThumbnail.result. 
	--- Check the result mapping for the 'thumbnailImgUrl' property.

	--- Cause: java.sql.SQLException: Exhausted Resultset
	at
	
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
	WithCallback(GeneralStatement.java:185)
	
	when we use plain select statement, it works fine. The way we
call
	stored procedures is:
	
	
	jdbcType="ORACLECURSOR" mode="OUT" resultMap="searchResult" />
	
	javaType="java.lang.String" mode="IN" resultMap="searchResult"/>
	
	mode="IN" resultMap="searchResult"/>
	
	javaType="java.lang.String" mode="IN" resultMap="searchResult"/>
	
	mode="IN" resultMap="searchResult"/>
	
	javaType="long" mode="IN" resultMap="searchResult"/>
	
	javaType="int" mode="IN" resultMap="searchResult"/>
	
	javaType="int" mode="IN" resultMap="searchResult"/>
	
	javaType="int" mode="IN" resultMap="searchResult"/> 
	
	
	
	
	{?=call pkg_object_adv_search_new.do_search_v3
	(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}
	
	
	In java :
	HashMap parameters = new HashMap();
	SqlMapClientTemplate client = getSqlMapClientTemplate();
	.
	.
	
	client.queryForList("searchAllCollections ",
	parameters);
	result = (List) parameters.get("o");
	
	Stored Procedure declaration:
	FUNCTION search_collections (
	keyword_words_in IN VARCHAR2,
	obj_type_id_in IN NUMBER,
	order_by_in IN VARCHAR2 DEFAULT ' sco1 desc, sco2 desc',
	outlength_in IN NUMBER DEFAULT 501,
	collection_ids_in IN VARCHAR2,
	thumbnail_only_in IN BOOLEAN
	)
	RETURN pkg_object_search_cursor.return_cur;
	
	Where return type is
	TYPE object_cur IS REF CURSOR
	
	When we accessing result from stored procedure, we got problem.
	Please help
	Sincerely,
	eugene





"Peace is found not in what surrounds us, but in what we hold within."

  


Re: Exhausted resultset exception when use Oracle REF cursor type as output parameter from Stored Procedure

Posted by BalaKishore Pamarti <bp...@yahoo.com>.
At the first glance I noticed these --
   
  You dont have to sepicify resultMap for all the IN parameters in parameterMap element.
   
  Your listed parameters in the parameterMap element are 9 and your ?'s in the procedure call are 14. think this should be 8

  There is not match for ur parameters specified in the stored procedure to those in parameterMap element.
   
  post the right code.

Eugene Dvorkin <Eu...@artstor.org> wrote:
  Hi,
We developed application with Spring, Hibernate and Ibatis. 
We use Oracle Application Server and configured database Connection Pool
provided by Application Server.
Then we start stress test our application and discovered problem that
appears only under load and only in a call to 
Stored Procedures than returns REF Cursor. 
Caused by: 
com.ibatis.common.jdbc.exception.NestedSQLException: 
--- The error occurred in org/artstor/pojo/CategoryThumbnail.xml. 
--- The error occurred while applying a result map. 
--- Check the CategoryThumbnail.result. 
--- Check the result mapping for the 'thumbnailImgUrl' property. 
--- Cause: java.sql.SQLException: Exhausted Resultset
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:185)

when we use plain select statement, it works fine. The way we call
stored procedures is:



jdbcType="ORACLECURSOR" mode="OUT" resultMap="searchResult" />

javaType="java.lang.String" mode="IN" resultMap="searchResult"/>

mode="IN" resultMap="searchResult"/>

javaType="java.lang.String" mode="IN" resultMap="searchResult"/>

mode="IN" resultMap="searchResult"/>

javaType="long" mode="IN" resultMap="searchResult"/>

javaType="int" mode="IN" resultMap="searchResult"/>

javaType="int" mode="IN" resultMap="searchResult"/>

javaType="int" mode="IN" resultMap="searchResult"/> 






{?=call pkg_object_adv_search_new.do_search_v3
(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}



In java :
HashMap parameters = new HashMap();
SqlMapClientTemplate client = getSqlMapClientTemplate();
.
.

client.queryForList("searchAllCollections ",
parameters);
result = (List) parameters.get("o");

Stored Procedure declaration:
FUNCTION search_collections (
keyword_words_in IN VARCHAR2,
obj_type_id_in IN NUMBER,
order_by_in IN VARCHAR2 DEFAULT ' sco1 desc, sco2 desc',
outlength_in IN NUMBER DEFAULT 501,
collection_ids_in IN VARCHAR2,
thumbnail_only_in IN BOOLEAN
)
RETURN pkg_object_search_cursor.return_cur;

Where return type is
TYPE object_cur IS REF CURSOR

When we accessing result from stored procedure, we got problem.
Please help
Sincerely,
eugene




"Peace is found not in what surrounds us, but in what we hold within."


       

Exhausted resultset exception when use Oracle REF cursor type as output parameter from Stored Procedure

Posted by Eugene Dvorkin <Eu...@artstor.org>.
Hi,
We developed application with Spring, Hibernate and Ibatis. 
We use Oracle Application Server and configured database Connection Pool
provided by Application Server.
Then we start stress test our application and discovered problem that
appears only under load and only in a call to 
Stored Procedures than returns REF Cursor. 
Caused by: 
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in org/artstor/pojo/CategoryThumbnail.xml.  
--- The error occurred while applying a result map.  
--- Check the CategoryThumbnail.result.  
--- Check the result mapping for the 'thumbnailImgUrl' property.  
--- Cause: java.sql.SQLException: Exhausted Resultset
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:185)

when we use plain select statement, it works fine. The way we call
stored procedures is:
<parameterMap id="searchCategoryParameters" class="map">
	<parameter property="o" javaType="java.sql.ResultSet"
jdbcType="ORACLECURSOR" mode="OUT" resultMap="searchResult" />
	<parameter property="keywords" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" resultMap="searchResult"/>
	<parameter property="objTypeId" jdbcType="NUMBER" javaType="int"
mode="IN" resultMap="searchResult"/>
	<parameter property="orderBy" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" resultMap="searchResult"/>
	<parameter property="outLength" jdbcType="NUMBER" javaType="int"
mode="IN" resultMap="searchResult"/>
	<parameter property="categoryId" jdbcType="NUMBER"
javaType="long" mode="IN" resultMap="searchResult"/>
	<parameter property="thumbnailOnly" jdbcType="NUMBER"
javaType="int" mode="IN" resultMap="searchResult"/>
	<parameter property="start_pos_in" jdbcType="NUMBER"
javaType="int" mode="IN" resultMap="searchResult"/>
	<parameter property="page_length_in" jdbcType="NUMBER"
javaType="int" mode="IN" resultMap="searchResult"/>  
</parameterMap>


<procedure id="searchAllCollection " parameterMap="searchParameters">
{?=call pkg_object_adv_search_new.do_search_v3
(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}
</procedure>

In java :
HashMap<Object, Object> parameters = new HashMap<Object, Object>();
SqlMapClientTemplate client = getSqlMapClientTemplate();
.
.

		client.queryForList("searchAllCollections ",
parameters);
		result = (List) parameters.get("o");

Stored Procedure declaration:
FUNCTION search_collections (
    keyword_words_in    IN   VARCHAR2,
    obj_type_id_in      IN   NUMBER,
    order_by_in         IN   VARCHAR2 DEFAULT ' sco1 desc, sco2 desc',
    outlength_in        IN   NUMBER DEFAULT 501,
    collection_ids_in   IN   VARCHAR2,
    thumbnail_only_in   IN   BOOLEAN
  )
    RETURN pkg_object_search_cursor.return_cur;

Where return type is
TYPE object_cur IS REF CURSOR

When we accessing result from stored procedure, we got problem.
Please help
Sincerely,
eugene