초보다아아아악
21
2020-11-09 03:11:01
3
150

DAOimpl에서 mapper로 연결할때,, 전달인자 2개 보내는데 에러가 납니다.



@Override
	public List<GoodsVO> goodsCategoryList(String category, Criteria cri) throws Exception {
				
		System.out.println("DAO : 카테고리 분류");
		
		  HashMap<String, Object> map = new HashMap<String, Object>();
		  map.put("category", category); 
		  map.put("cri", cri);
			
		return sqlSession.selectList(namespace+".category",map);
	}
	



<!-- 카테고리별 상품 목록 -->
 	<select id="category" resultType="com.bestpricemarket.domain.GoodsVO">
 		select * 
 		from goods 
 		where category = #{category} 
 		order by gno desc, regDate desc
 		limit #{pageStart},#{pageSize}
 	</select>
 	<!-- 카테고리별 상품 분류 -->


** 500에러


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
### The error may exist in file [D:\workspace_STS7\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bestPriceMarket\WEB-INF\classes\mappers\goodsMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select *     from goods     where category = ?     order by gno desc, regDate desc    limit ?,?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

근본 원인 (root cause)

org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
### The error may exist in file [D:\workspace_STS7\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bestPriceMarket\WEB-INF\classes\mappers\goodsMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select *     from goods     where category = ?     order by gno desc, regDate desc    limit ?,?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
	org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
	org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
	org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)
	com.sun.proxy.$Proxy31.selectList(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
	com.bestpricemarket.persistence.GoodsDAOImpl.goodsCategoryList(GoodsDAOImpl.java:59)
	com.bestpricemarket.service.GoodsServiceImpl.goodsCategoryList(GoodsServiceImpl.java:64)
	com.bestpricemarket.controller.GoodsController.goodsListGET(GoodsController.java:96)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

근본 원인 (root cause)

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null,null' at line 5
	java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
	java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
	com.mysql.jdbc.Util.getInstance(Util.java:408)
	com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
	com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
	com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
	com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)
	com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)
	com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2501)
	com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
	com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1197)
	net.sf.log4jdbc.sql.jdbcapi.PreparedStatementSpy.execute(PreparedStatementSpy.java:443)
	org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
	org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
	org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
	org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
	org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
	org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
	org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
	org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
	org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
	com.sun.proxy.$Proxy31.selectList(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
	com.bestpricemarket.persistence.GoodsDAOImpl.goodsCategoryList(GoodsDAOImpl.java:59)
	com.bestpricemarket.service.GoodsServiceImpl.goodsCategoryList(GoodsServiceImpl.java:64)
	com.bestpricemarket.controller.GoodsController.goodsListGET(GoodsController.java:96)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

비고 근본 원인(root cause)의 풀 스택 트레이스를, 서버 로그들에서 확인할 수 있습니다.


daoImpl에서 mapper로 연결을 하는데 전달변수 category와 cri 두개를 전달하는데 

selectList에 한개밖에 전달이 안되어서 

map객체로 만들어서 전달했습니다.

그런데 Criteria cri의 paseStart, pageSize 값이 전달이 되지 않아 에러가 나는 거 같은데 

혹시 제가 잘못 코딩을 한걸까요..?

방법을 모르겠네요..

0
  • 답변 3

  • C#린이
    2k
    2020-11-09 08:30:58

    #{pageStart}, #{pageSize} 에 값을 전달하지 않아

    null, null 이 뜬다고 나와있네요.

    위 두 파라미터 관련해서 DaoImpl 에 언급된 부분이 없네요.

  • rezigrene
    1k
    2020-11-09 09:57:22

    cri.pageStart

    cri.pageSize

  • 초보다아아아악
    21
    2020-11-09 11:15:19

    헉 너무 감사드려요!! 해결했어요!! 두분 다 감사드립니다ㅠㅠ

  • 로그인을 하시면 답변 을 등록할 수 있습니다.