Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation error about the select statement located in separate mapper xml with same mapper namespace #86

Closed
Prachi481992 opened this Issue Jul 18, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@Prachi481992
Copy link

Prachi481992 commented Jul 18, 2018

I'm trying to use a select statement defined in one mapper file in the association in the resultmap of another mapper xml. Both the mapper xmls have the same namespace. I'm using the fully qualified name to refer the select. But the same select is accessible by hyperlink. The code works fine at runtime.
Below is the mapper file which needs to be imported:

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.abc.MybatisMapper">
	<!-- add column names only -->
    <select id="getADetails" resultType="com.abc.dto.A">
        SELECT a.id,
         a.name
        FROM
        TABEL_A
        <trim prefix="WHERE" prefixOverrides="AND | OR">
            a.id = #{id}
        </trim>
    </select>
</mapper>

Below is the mapper file which uses the select in first mapper file:

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.abc.MybatisMapper">

    <resultMap id="resultmapB" type="com.abc.dto.B">
       <result property="b_id" column="b_id" />
        <result property="b_name" column="b_name" />
        <association property="a_details" javaType="com.abc.dto.A" column="a_id" select="com.abc.MybatisMapper.getADetails" />
    </resultMap>
<!-- add column names only -->
    <select id="getBDetails" resultMap="resultmapB">
        SELECT b_id,
		b_name,
		a_id
        FROM
        TABEL_B
        <trim prefix="WHERE" prefixOverrides="AND | OR">
            b_id = #{id}
        </trim>
    </select>
</mapper>

The line in second file which declares the association gives the compilation error.

@harawata

This comment has been minimized.

Copy link
Member

harawata commented Jul 18, 2018

You're right. When I wrote that part, I didn't realize that it was possible to specify the same namespace in multiple XML mappers.
It may take some time for me to fix it as it will require a major rewrite.

@harawata harawata added this to the 1.1.2 milestone Jul 22, 2018

@harawata harawata added the bug label Jul 22, 2018

@harawata harawata self-assigned this Jul 22, 2018

@harawata harawata closed this in 0033c18 Jul 24, 2018

@harawata

This comment has been minimized.

Copy link
Member

harawata commented Jul 24, 2018

@Prachi481992
This should be fixed in 1.1.2 (let me know if it's not).
Thank you for taking the time to report this!

@Prachi481992

This comment has been minimized.

Copy link
Author

Prachi481992 commented Jul 26, 2018

@harawata
The issue is resolved now.
Thanks for the quick resolution!

@harawata

This comment has been minimized.

Copy link
Member

harawata commented Jul 26, 2018

Great. Thank you for your help, @Prachi481992 ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.