1. mybatis sql 태그 내 쿼리를 주석 처리 할 때,
2. mybatis sql 태그 전체를 주석 처리 할 때,
■ xml 주석처리 , 주석 단축키 2017. 5. 16. 19:04ㆍBASIC/android * xml 주석처리 <!--android:src="@drawable/"--> * 주석 단축키 1. 주석처리하기 위한 코드를 드래그한다. 2. Ctrl + Shift + / 'BASIC > android' 카테고리의 다른 글
관련글
댓글 0
댓글 비공개 Jakarta iBatis 쿼리 작성 XML에서 /* */ 주석 달 때 오류..원문 : http://kwon37xi.egloos.com/ iBatis 쿼리 작성 XML에서 /* */ 주석 달 때 오류..iBatis 쿼리 XML을 작성할 때 오라클의 주석문인 /* */을 적으면서 꼭 공백을 넣어야 한다. 1. /*주석*/ : 요고 안돼요~ 2. /* 주석 */ : 요고 돼요~ 안그러면.. 다음과 같은 오류 발생.. SqlMapClient operation; uncategorized SQLException for SQL ; SQL state null; error code [0]; --- The error occurred while applying a parameter map. --- Check the query-id-InlineParameterMap. --- Check the results (failed to retrieve results). --- Cause: java.lang.NullPointerException; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred while applying a parameter map. --- Check the query-id-InlineParameterMap. --- Check the results (failed to retrieve results). --- Cause: java.lang.NullPointerException iBatis 동적 생성 쿼리(<iterate>)시 이전 컬럼 정보를 가지고 현재 컬럼정보에 강제 매핑하는 현상.. iBatis는 일단 쿼리를 실행하고 나면 그 쿼리 ID에 대해 결과를 저장하는 컬럼들 정보를 캐싱하고 있다가, 다음번 쿼리때 그 컬럼 정보들을 재사용한다. 헌데, 나같은 경우 현재 컬럼 자체를 <iterate>를 이용해 동적으로 생성하기 때문에 동일한 ID의 쿼리라도 실제 쿼리 결과로 돌아오는 컬럼들이 항상 다르다. 이 경우 iBatis가 예전 쿼리의 컬럼 정보에 따라 쿼리 결과를 매핑하려 들기때문에 없는 쿼리에 대한 결과를 요청하는 사태가 발생한다. <select remapResults="true" .... 위와 같이 remapResults="true" 을 사용하면 컬럼 정보를 쿼리 할 때마다 가져와서 문제가 해결된다. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="boardDAO"> <insert id="insertArticle" parameterType="ArticleVO">
INSERT INTO ARTICLE(ID, SUBJECT, CONTENT) 파라미터 표기법 #{} VALUES(ARTICLE_SEQ.NEXTVAL,#{subject}, #{content}) <selectKey keyProperty="id" resultType="_int" order="AFTER"> SELECT ARTICLE_SEQ.CURRVAL FROM DUAL </selectKey> </insert> <resultMap type="ArticleVO" id="getArticleInfoByIdMap"> <id property="id" column="ART_ID"/> <result property="subject" column="SUBJECT"/> <result property="content" column="CONTENT"/> </resultMap> SELECT ID, SUBJECT, CONTENT FORM ARTICLE WHERE ? 와 같음 <select id="getArticleInfoById" resultMap="getArticleInfoByIdMap" parameterType="_int"> SELECT ID as ART_ID, SUBJECT, CONTENT FROM ARTICLE WHERE ID = #{id} </select> <!-- /* MyBatis에서는 파라미터를 샵{}로 표현한다.쿼리에서는 쿼리전용주석이필요하다. */ --> <select id="getAllArticleInfo" resultMap="getArticleInfoByIdMap"> SELECT ID as ART_ID, SUBJECT, CONTENT FROM ARTICLE </select> <update id="updateArticleInfoById" parameterType="hashmap"> UPDATE ARTICLE <set> <if test="subject != null"> SUBJECT = #{subject} </if> <if test="content != null"> , CONTENT = #{content} </if> </set> WHERE ID = #{id} </update> <!--바뀌거만 업뎃해주자해서 다이나믹쿼리를써야함 --> <delete id="deleteArticleInfoById" parameterType="_int"> DELETE FROM ARTICLE WHERE ID = #{id} </delete> </mapper> |