Includes don't check the namespace?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Includes don't check the namespace?

Jin Kwon
<mapper namespace="...AMapper">
  <sql id="sqlA">
  </sql>
  <sql id="sqlB">
  <include refid="sqlA"/>
  </sql>
</mapper>

<mapper namespace="...BMapper">
  <sql id="sqlC">
    <include refid="...AMapper.sqlB"/>
  </sql>
</mapper>

Could not find SQL statement to include with refid '...BMapper.sqlA'] with root cause

This this normal?

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Includes don't check the namespace?

Erwan Letessier
Yes it is: 
Including a block containing includes is just like a runtime copy/paste.
That means  that from BMapper, block sqlA included in AMapper.sqlB is considered relatively to the caller (BMapper)
Then you must explicitly include it with fully qualified name:

<mapper namespace="...AMapper">
 
<sql id="sqlA">
 
</sql>
 
<sql id="sqlB">
 
 <include refid="...AMapper.sqlA"/>
 
</sql>
</mapper>

On the other hand, include of include without qualified name allows simulating kind of inheritance.

Cheers

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.