tags:

views:

182

answers:

0

I am getting No SqlMapClient specified error

I have spring-for-ibatis.xml that has the following

<bean id="MySqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sql-map-config-oracle.xml"/>
  <property name="dataSource" ref="IbatisDataSourceOracle"/>
 </bean>
<bean id="IbatisDataSourceOracle" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/RSRC/comp/my/oltp"/>
</bean>
  <bean id="phaDisasterTenantIncomeDAO" class="reports.IncomeDAO">
    <property name="sqlMapClient" ref="MySqlMapClient"/>
    <property name="dataSource" ref="IbatisDataSourceOracle"/>
 </bean>

I've got the following in sql-map-config-oracle.xml

<sqlMap resource="Income.xml"/>

Inside IncomeDAO I am doing the following

getSqlMapClientTemplate().queryForList("IncomeName.parmId", parmMap);

At the above line I am getting No SqlMapClient specified error.

Call to the DAO is simply

myBean = incomeDAO.getIncome(empId);

I understand that with spring ...an interface needs to be made corresponding to the DAO and before calling any method in the DAO the bean should be fetched like this:

ApplicationInitializer.getApplicationContext().getBean("myBean")

however, I want to avoid that. I want to be able to make simple calls to the DAO as mentioned above. I am changing a lot of DAO and changing 'callers' for each will be a PITA.

My question simply is. ...how can I use iBatis from inside a DAO that was not called by calling application context. Can I just call application context inside the bean??