I just looked in the code to try to figure this out. It looks like
this could happen if you have an identity field that is at the end of
the list of columns (maybe the last column in the table). I'll write
some code to guard against this for the next release, but that does
not appear to be the case in your table.
In your case, HOLDING_ID is not an identity field. An identity field
has it's value automatically generated on insert by the database (an
autonumber field). That is not the case here - you have a field that
is set from a sequence and the <selectKey> should run BEFORE the
statement executes. You should change the <generatedKey>
configuration - remove the identity=true attribute and set type=pre.
Jeff Butler
On Wed, Sep 5, 2012 at 9:37 AM, Paul Krause <
paulkr...@alum.mit.edu> wrote:
> I am using MyBatis 3.1.1.
>
> Recently, I have started getting an extra trailing comma at the end of some
> the insert statements generated by MyBatis Generator. I am unable to figure
> out what change introduced this behavior. Does anyone have a clue?
>
> The generated XML looks like this (with unrelated lines removed for clarity)
>
> <insert id="insert" parameterType="com.mycompany.Holding">
> <!--
> WARNING - @mbggenerated
> This element is automatically generated by MyBatis Generator, do not
> modify.
> -->
> <selectKey keyProperty="holdingId" order="AFTER" resultType="String">
> <include refid="selectIdFromSequence" />
> </selectKey>
> insert into HOLDING (ACC_ID, CANCEL_DATE, CLOSE_DATE,
> ACCRUED_INTEREST, )
> values (#{accId,jdbcType=DECIMAL}, #{cancelDate,jdbcType=TIMESTAMP},
> #{closeDate,jdbcType=TIMESTAMP},
> #{accruedInterest,jdbcType=FLOAT}, )
> </insert>
>
>
> The generator config XML looks like this
>
>
> <table tableName="HOLDING" enableCountByExample="false"
> enableDeleteByExample="false" enableSelectByExample="false"
> enableUpdateByExample="false">
> <property name="rootInterface" value="CustomHoldingMapper"/>
> <property name="rootClass" value="AbstractHolding"/>
> <generatedKey column="HOLDING_ID" identity="true" type="post"
> sqlStatement="<include refid="selectIdFromSequence" />" />
> <columnOverride column="ACC_ID" javaType="String" />
> <columnOverride column="ACCRUED_INTEREST" javaType="double"/>
> <columnOverride column="CANCEL_DATE" javaType="java.sql.Timestamp" />
> <columnOverride column="CLOSE_DATE" javaType="java.sql.Date" />
> </table>
>
> Thanks,
> Paul
>