ibatis는 XML에 정의하다보니... 깜빡깜빡 하는게 있는데
부등호 (즉 < , > ) 를 기냥 쓰게 되면 오류가 난다. (태그에 존재하는 <tag> 꺽쇠랑 동일하기 때문에 파싱에러발생)
이때는 <![CDATA[ ]]> 로 감싸주면 된다
부등호 (즉 < , > ) 를 기냥 쓰게 되면 오류가 난다. (태그에 존재하는 <tag> 꺽쇠랑 동일하기 때문에 파싱에러발생)
이때는 <![CDATA[ ]]> 로 감싸주면 된다
<select id="select" resultClass="DischargePointData" parameterClass="Map">
SELECT
seq as seq
, note as note
FROM
table
user_id = #userId#
<isNotEmpty prepend="AND" property="startYYYYMM" removeFirstPrepend="true">
<![CDATA[
reg_date >= str_to_date(concat('#startYYYYMM#','01000000'),'%Y%m%d%H%i%s')
]]>
</isNotEmpty>
</select>
SELECT
seq as seq
, note as note
FROM
table
user_id = #userId#
<isNotEmpty prepend="AND" property="startYYYYMM" removeFirstPrepend="true">
<![CDATA[
reg_date >= str_to_date(concat('#startYYYYMM#','01000000'),'%Y%m%d%H%i%s')
]]>
</isNotEmpty>
</select>
참고로 <![CDATA[ ]]> 로 안감싸주고 <> 를 쓰게 되면
아래와 같은 오류가 난다.
java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at com.konantech.memetracker.ibatis.SqlMap.<clinit>(SqlMap.java:23)
at com.konantech.memetracker.action.ActionPaymentPoint.<clinit>(ActionPaymentPoint.java:68)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 3 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
... 4 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 8 more
Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
... 11 more
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at com.konantech.memetracker.ibatis.SqlMap.<clinit>(SqlMap.java:23)
at com.konantech.memetracker.action.ActionPaymentPoint.<clinit>(ActionPaymentPoint.java:68)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 3 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
... 4 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 8 more
Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
... 11 more