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 Mikael Andersson <ma...@gmail.com> on 2007/04/10 10:37:11 UTC

Re: problem with simple

Found the problem, and posting it just in case another newbie runs into it.

By habit I injected the datasource into my DAO's( in the spring
configuration), which is a big nono. When only injecting the datasource into
the sql map client it all works fine.

- Mike

On 30/03/07, Mikael Andersson <ma...@gmail.com> wrote:
>
> Hi guys,
> I have a problem which I suspect is solved by simple means, but I've been
> trying to solve this for the past couple of hours and I can't figure it out.
>
> I have a simple bean that contains a List of some other beans, I try to
> populate this inner list with a nested select statement. My company won't be
> happy if I post internal code,  ;(  , so if things look a little strange it
> is because I had to change it a bit.
>
>
> <select id="tstGetBond" parameterClass="int" resultMap="BondVOResultTst">
>     select .........
> </select>
> <resultMap class="BondVO" id="BondVOResultTst"
> extends="InstrumentVOResult">
>         <result column="id" property="bondRatings"
> select="dbo_INSTRUMENT.getBondRatings"/>
> </resultMap>
>
> <select id="getBondRatings" parameterClass="int"
> resultMap="BondRatingVOResult">
>         select
>             id,
>             rating
>         from
>             dbo.BOND_RATING_TABLE
>         where
>             id = #value#
> </select>
> <resultMap class="BondRatingVO" id="BondRatingVOResult">
>         <result column="id" jdbcType="NUMERIC" property="id"/>
>         <result column="rating" jdbcType="VARCHAR" property="rating"/>
> </resultMap>
>
>
> The error I get is this:
>
> --- The error occurred in com/test/sqlmap/dbo_INSTRUMENT_SqlMap.xml.
> --- The error occurred while applying a result map.
> --- Check the dbo_INSTRUMENT.BondVOResultTst.
> --- Check the result mapping for the 'bondRatings' property.
> --- Cause: java.lang.NullPointerException; nested exception is
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in com/test/sqlmap/dbo_MFI_INSTRUMENT_SqlMap.xml.
> --- The error occurred while applying a result map.
> --- Check the dbo_INSTRUMENT.BondVOResultTst.
> --- Check the result mapping for the 'bondRatings' property.
> --- Cause: java.lang.NullPointerException
> DEBUG (
> org.springframework.transaction.interceptor.RuleBasedTransactionAttribute)
> - Applying rules to determine whether transaction should rollback on
> org.springframework.jdbc.UncategorizedSQLException: SqlMapClient
> operation; uncategorized SQLException for SQL []; SQL state [null]; error
> code [0];
> --- The error occurred in com/test/sqlmap/dbo_MFI_INSTRUMENT_SqlMap.xml.
> --- The error occurred while applying a result map.
> --- Check the dbo_NSTRUMENT.BondVOResultTst.
> --- Check the result mapping for the 'bondRatings' property.
> --- Cause: java.lang.NullPointerException; nested exception is
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in com/test/sqlmap/dbo_INSTRUMENT_SqlMap.xml.
> --- The error occurred while applying a result map.
> --- Check the dbo_MFI_INSTRUMENT.BondVOResultTst.
> --- Check the result mapping for the 'bondRatings' property.
> --- Cause: java.lang.NullPointerException
>
> Any help appreciated.
>
> Cheers,
>  Mike
>

Re: problem with simple

Posted by andreafey <an...@noaa.gov>.
Thanks, nmaves. My config is the same as yours now. Mike_'s response helped
me reorganize it. 

For the sake of helping others, this was the configuration which worked with
an earlier release, but not 2.3.0:

  <bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
	<property name="configLocation" value="classpath:sql-map-config.xml"/>
  </bean>

  <bean id="stationDao"   class="abc.def.dao.ibatis.StationDao">
      <property name="sqlMapClient"><ref local="sqlMapClient"/></property>
      <property name="dataSource"><ref bean="dataSource"/></property>
  </bean>




nmaves wrote:
> 
> you might want to post your spring config file where you configure your
> datasource and sqlmap clients.
> 

-- 
View this message in context: http://www.nabble.com/problem-with-simple-%3Cresult-...-select%3D..-%3E-tf3492459.html#a10142163
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: problem with simple

Posted by Nathan Maves <na...@gmail.com>.
you might want to post your spring config file where you configure your
datasource and sqlmap clients.

Here is what I use.


        <bean id="propertyConfigurer" class="
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location" value="classpath:database.properties
"/>
        </bean>

    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="${driver}" />
        <property name="url" value="${url}" />
        <property name="username" value="${username}" />
        <property name="password" value="${password}" />
    </bean>

    <bean id="sqlMapClient"
          class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation"
                  value="classpath:ibatis.xml" />
        <property name="dataSource" ref="dataSource" />
        <property name="useTransactionAwareDataSource" value="true" />
    </bean>

On 4/20/07, andreafey <an...@noaa.gov> wrote:
>
>
> I am in the process of upgrading to Spring 2.0.4 from 1.2.8 and began with
> an
> upgrade to Ibatis (from 2.x to 2.3.0). All of my DAOs were injected with
> the
> datasource, and the nested select worked before the upgrade. This fixed
> the
> introduced NPE.
> Thanks,
> Andrea
>
>
> Mike_ wrote:
> >
> > Found the problem, and posting it just in case another newbie runs into
> > it.
> >
> > By habit I injected the datasource into my DAO's( in the spring
> > configuration), which is a big nono. When only injecting the datasource
> > into
> > the sql map client it all works fine.
> >
>
> --
> View this message in context:
> http://www.nabble.com/problem-with-simple-%3Cresult-...-select%3D..-%3E-tf3492459.html#a10102921
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: problem with simple

Posted by andreafey <an...@noaa.gov>.
I am in the process of upgrading to Spring 2.0.4 from 1.2.8 and began with an
upgrade to Ibatis (from 2.x to 2.3.0). All of my DAOs were injected with the
datasource, and the nested select worked before the upgrade. This fixed the
introduced NPE.
Thanks,
Andrea


Mike_ wrote:
> 
> Found the problem, and posting it just in case another newbie runs into
> it.
> 
> By habit I injected the datasource into my DAO's( in the spring
> configuration), which is a big nono. When only injecting the datasource
> into
> the sql map client it all works fine.
> 

-- 
View this message in context: http://www.nabble.com/problem-with-simple-%3Cresult-...-select%3D..-%3E-tf3492459.html#a10102921
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.