Announcement Announcement Module
Collapse
No announcement yet.
Why is autowired sql client not reading database statements? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why is autowired sql client not reading database statements?

    Hi,

    I'm using Spring 3.0, Tomcat 6.0.26, Java 1.6, and iBatis 2.3 (SQL ORM package). In my @Configuration class, I have ...

    Code:
    @Configuration
    @ImportResource("securityContext.xml")
    public class Application {
    
    	@Bean(name = "sqlMapClient")
    	@Autowired
    	public SqlMapClientFactoryBean sqlMapClient(@Qualifier("dataSource") DataSource dataSource) {
    		SqlMapClientFactoryBean factory = new SqlMapClientFactoryBean();
    		factory.setConfigLocation(new ClassPathResource("sqlMapConfig.xml"));
    		factory.setDataSource(dataSource);
    		return factory;
    	}
    	...
    And the contents of my "sqlMapConfig.xml" file are ...

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
    
    <sqlMapConfig>
            <settings
                    cacheModelsEnabled="true"
                    enhancementEnabled="true"
                    maxSessions="128"
                    maxTransactions="16"
                    maxRequests="256"
                    useStatementNamespaces="true"
            />
    
            <sqlMap resource="com/myco/persistence/ibatis/user.xml" />
            <sqlMap resource="searchResultSQLMaps.xml" />
            <sqlMap resource="mesquiteQueries.xml" />
    
    </sqlMapConfig>

    but from my @Controller, when I try and execute a query ...

    Code:
    @Controller
    public class MeetInMesquiteController {
    
    	@Autowired
    	@Qualifier("sqlMapClient")
    	private SqlMapClient sqlMapClient;
    ...
    List<SearchResultHotels> spaceDetails = sqlMapClient.queryForList(SQLNames.GET_MESQUITE_ACCOMMODATION_DETAILS, spaceId);
    I get the error, "org.springframework.web.util.NestedServletExcepti on: Request processing failed; nested exception is com.ibatis.sqlmap.client.SqlMapException: There is no statement named Mesquite.getMesquiteAccommodationDetails in this SqlMap", despite the fact that the named query is in a resource mapped in my sqlMapConfig.xml file. Any ideas how I can troubleshoot this further? There are no exceptions reported upon application startup.

    Thanks, - Dave
Working...
X