IBatis sql fragments used in different namespace
I've got a sql fragments defined in a particular namespace like:
<sqlMap namespace="firstNamespace">
.....
<sql id="fragmentOne">
and then from another namespace I'm trying to use it, but seems that IBatis is not able to find it.
Could not find SQL statement to include with refid 'firstNamespace.fragmentOne'
Now I know that the loading order is important, so the SqlMapCon开发者_如何学Gofig.xml file I place the xml file containing the fragment first, but no results.
Do you have any idea on how to use a sql fragment from another namespace?
Thanks Roberto
Have you enabled namespaces?
<sqlMapConfig>
<settings useStatementNamespaces="true"/>
Reference:
http://java.ociweb.com/mark/programming/iBATIS.html
Besides, be carefull to put XML files in right order inside sqlMapConfig.Xml.
<sqlMapConfig>
<settings useStatementNamespaces="true" /> <!-- add this line -->
<sqlMap resource="ibatis/Web-Registration-Report.xml" />
</sqlMapConfig>
Note:
It easy enough to solve the problem, just add the line below in iBatis Configuration and make sure, now use the namespace when calling it.
Be aware. Since now, code will produce error if you are not using the namespace. So it will be wiser to make a final decision whether to use the namespace or not.
精彩评论