emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

Allow <include refid="othermapper.fragment"> to be used in Configuration.addMapper() #133

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?
MyBatis 3.0.2

Please describe the problem.  Unit tests are best!
When a mapper is added using Configuration.addMapper() and this mapper's XML 
file use an <include> that refers to another mapper's fragment, it throws an 
exception.
<include> should be allowed to get fragments from other XML files.

What is the expected output? What do you see instead?
Normal configuration should allow use of fragments from other mappers as the 
XMLConfigurationBuilder does.

Please provide any additional information below.
Unit test and patch are included in patch.txt file.

Original issue reported on code.google.com by christia...@ircm.qc.ca on 8 Oct 2010 at 1:19

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by christia...@ircm.qc.ca on 8 Oct 2010 at 1:43

GoogleCodeExporter commented 9 years ago
New test case and patch since mixed configuration was not tested.

Original comment by christia...@ircm.qc.ca on 8 Oct 2010 at 1:52

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by christia...@ircm.qc.ca on 8 Oct 2010 at 2:06

GoogleCodeExporter commented 9 years ago
I'm working in a project that uses 3.0.3, however we are adding the mappers 
differently, eg:

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

......

       <property name="mapperLocations">
            <array>
                <value>classpath:/org/xyz/domain/mapping/*.xml</value>
                <value>classpath:/org/xyz/abc/domain/mapping/*.xml</value>
                <value>classpath:/org/xyz/def/domain/mapping/*.xml</value>
            </array>
        </property> 

.....

</bean>

Unfortunately I cannot seem to access sql fragments defined in other XML files. 
 Should this be possible with the above config, or is this a similar issue?  

Original comment by am2...@gmail.com on 21 Dec 2010 at 12:09

GoogleCodeExporter commented 9 years ago
With my patch order still matters­. I suppose that the order in which your 
files are read is not the order you expect. This may be an issue with Spring an 
not my patch specifically.
I recommend you to check out the trunk version and try again. As you can see in 
issue 179, the order restriction was removed in the trunk (future version 
3.0.4). If you see an issue with the trunk version, I'll have a deeper look.

Thanks for the update!

Original comment by christia...@ircm.qc.ca on 21 Dec 2010 at 2:05

GoogleCodeExporter commented 9 years ago
There is a bug in mybatis-spring where mappers added via SqlSessionFactoryBean 
mapperLocations cannot access sql fragments in other XML files so I've created 
issue 222 (includes patch).

Original comment by patrick....@3pillarglobal.com on 5 Jan 2011 at 10:12