xml을 통해 sql문들을 불러올 키인 'name' 이 중복될 경우 키가 중복된다고
Duplicate <sql>-include ... found 에러가 뜨게 된다.

com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/sql'.  Cause: com.ibatis.sqlmap.client.SqlMapException: Duplicate <sql>-include 'select-all' found.
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
account.joinAction.<init>(joinAction.java:45)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:123)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:154)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:113)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:275)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
 

이런 문제는 namespace를 통해 해결할 수 있으나
namespace를 쓰기 위해서는 ibatis 설정에서 사용이 가능하도록 설정 해주어야 한다.
useStatementNamespaces 는 기본값이 false이다.
Example: useStatementNamespaces=”false”
Default: false (disabled)
 
[링크 : http://ibatis.apache.org/docs/dotnet/datamapper/ch04s03.html


/src/sqlMapConfig.xml

<sqlMapConfig>
<properties resource="/dbconnect.properties" />
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="1" maxSessions="1"
maxTransactions="1" useStatementNamespaces="true" />

<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}" />
<property name="JDBC.ConnectionURL" value="${url}" />
<property name="JDBC.Username" value="${username}" />
<property name="JDBC.Password" value="${password}" />
</dataSource>
</transactionManager>

<sqlMap resource="/sql/external.xml"/>
</sqlMapConfig> 

/src/sql/external.xml

<sqlMap namespace="user_namespace">
</sqlMap>

[링크 : http://www.okjsp.net/seq/89041]
Posted by 구차니