UseGeneratedKey issue when upgrading to 3.5.0

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

UseGeneratedKey issue when upgrading to 3.5.0

葛俊

Hi
I’m upgrading mybatis 3.4.6 to 3.5.0 but find a compatibility issue.

Here is my java code and xml.

    int insertSelective(@Param("a") A a);

    <insert id="insertSelective" useGeneratedKeys="true" keyProperty="a.id">
        INSERT INTO a
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="a.id!=null"> id,</if>
            <if test="a.userId!=null"> user_id,</if>
            <if test="a.delete!=null"> `delete`,</if>
            <if test="a.mydate!=null"> mydate,</if>
        </trim>
        VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="a.id!=null">#{a.id,jdbcType=INTEGER},
            </if>
            <if test="a.userId!=null">#{a.userId,jdbcType=INTEGER},
            </if>
            <if test="a.delete!=null">#{a.delete,jdbcType=INTEGER},
            </if>
            <if test="a.mydate!=null">#{a.mydate,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>

when using with 3.4.6 the code works fine, 3.5.0 will throw exception

Caused by: org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'a.id' in 'com.lalalalssss.A'.

at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.getTypeHandlers(Jdbc3KeyGenerator.java:168)

at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.assignKeysToParam(Jdbc3KeyGenerator.java:138)

at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:71)

... 35 more

When i change the useGenerated key to id instead of a.id, the problem solved.

So is this behavior by design?If not, I think i can make a pull request for it.


Thanks.

--
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: UseGeneratedKey issue when upgrading to 3.5.0

葛俊
After view the github issues, this is fixed already. Hope 3.5.1 will out soon.

Thanks.

--
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.