Alex Sherwin
2010-02-08 14:40:36 UTC
I'm trying to create a "common" Sql Map XML file that will contain some
common fragments. In iBatis 2.x this was easy enough, the fragments
were referenced by other Sql Map files by using <include
refid="fully.qualified.ns.Statement"/>
I assumed the same would be true for iBatis 3.x as well, but doesn't
seem to be working for me. Right now, the only mapper I have in my
config xml in the <mappers> element is my common xml fragment, while the
rest of my mappers are registered with iBatis programatically. I gave
my common Sql Map a namespace of "common", and tried to reference a
statement from another SqlMap with <sql refid="common.params"/>, I see
this exception:
java.lang.RuntimeException: Error parsing Mapper XML. Cause:
org.apache.ibatis.builder.BuilderException: Could not find SQL statement
to include with refid 'common.params'
Now, in iBatis 2.x I know all of the statements were validated when the
configuration was loaded, so any commonly used fragments had to be
registered first. This might be my problem here, however, I don't know
how to check if that's true since my regular mappers are loaded
programatically and the common is configured in the configuration XML
common fragments. In iBatis 2.x this was easy enough, the fragments
were referenced by other Sql Map files by using <include
refid="fully.qualified.ns.Statement"/>
I assumed the same would be true for iBatis 3.x as well, but doesn't
seem to be working for me. Right now, the only mapper I have in my
config xml in the <mappers> element is my common xml fragment, while the
rest of my mappers are registered with iBatis programatically. I gave
my common Sql Map a namespace of "common", and tried to reference a
statement from another SqlMap with <sql refid="common.params"/>, I see
this exception:
java.lang.RuntimeException: Error parsing Mapper XML. Cause:
org.apache.ibatis.builder.BuilderException: Could not find SQL statement
to include with refid 'common.params'
Now, in iBatis 2.x I know all of the statements were validated when the
configuration was loaded, so any commonly used fragments had to be
registered first. This might be my problem here, however, I don't know
how to check if that's true since my regular mappers are loaded
programatically and the common is configured in the configuration XML