Announcement Announcement Module
Collapse
No announcement yet.
IBatis integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IBatis integration

    I am a beginner at the spring and I want to move DAO object from ibatis into spring. The code and error you can see further.

    Please help me to investigate the problem.

    <ERROR />
    java.lang.IllegalArgumentException: No SqlMapClient specified
    at org.springframework.util.Assert.notNull(Assert.jav a:90)

    <SPRING/>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

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

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

    <bean id="sqlMapClient"
    class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
    <property name="configLocation">
    <value>classpath:com/portal/daoconf/sql-map-config.xml</value>
    </property>
    <property name="useTransactionAwareDataSource">
    <value>true</value>
    </property>
    <property name="dataSource">
    <ref bean="dataSource"/>
    </property>
    </bean>

    <bean id="sqlMapClientTemplate"
    class="org.springframework.orm.ibatis.SqlMapClient Template">
    <property name="sqlMapClient">
    <ref bean="sqlMapClient"/>
    </property>
    </bean>

    <bean id="actionDao" class="portal.com.portal.dao.ActionDAO">
    <property name="sqlMapClient">
    <ref bean="sqlMapClient"/>
    </property>
    </bean>

    </beans>

    <DAO/>
    public class ActionDAO extends SqlMapClientTemplate implements ActionDAOInterface {
    public List getActionsRus( Object parameterObject ) throws DataAccessException {
    return queryForList( "NewsSQL.getActionsRus", parameterObject ) ;
    }
    }

    <MODEL/>
    public class ActionsIbatisModel {

    private static ActionDAO dao = new ActionDAO() ;

    public List getActionsRus( News ac )
    { return dao.getActionsRus( ac ) ; }

    }

  • #2
    The problem here is that you are creating your ActionDAO using the new operator. This means it's not managed by Spring and hence your dependencies aren't injected. You need to inject your reference or look it up from the applicationContext. The first option is preferable.
    http://www.springframework.org/docs/...s-dependencies

    Comment


    • #3
      yes!, of course ! Thank you a lot !

      Comment


      • #4
        Not a problem, glad the information as useful. Just a note for future, it really helps if you put your code in [ code] [ /code] tags, it's soooo much easier to read!

        Comment


        • #5
          sorry. of course.

          Comment


          • #6
            That cool. It's just lots easier to read and there's more chance of getting people to answer if they can read it .

            Comment

            Working...
            X