mybatis gets fake result when I want to get Generated Keys(batch insert with ignore)

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

mybatis gets fake result when I want to get Generated Keys(batch insert with ignore)

杨雨辰
<insert id="batchRecord" parameterType="List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT IGNORE INTO user_info(
VALUES
<foreach collection="list" item="item" separator=",">
      #{item.username,jdbcType=VARCHAR}
</foreach>
</insert>

I want to get generated keys when i insert ingore to the table,but the result is not right. table of user_info has an unique key about username ,so it cannot be written to the table
if the table already has this record. 
using this method ,the result ge a fake result . generated key cannot match the certain record.

--
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: mybatis gets fake result when I want to get Generated Keys(batch insert with ignore)

Kazuki Shimizu
Does not support this case.



On Sunday, April 29, 2018 at 6:57:57 PM UTC+9, 杨雨辰 wrote:
<insert id="batchRecord" parameterType="List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT IGNORE INTO user_info(
VALUES
<foreach collection="list" item="item" separator=",">
      #{item.username,jdbcType=VARCHAR}
</foreach>
</insert>

I want to get generated keys when i insert ingore to the table,but the result is not right. table of user_info has an unique key about username ,so it cannot be written to the table
if the table already has this record. 
using this method ,the result ge a fake result . generated key cannot match the certain record.

--
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: mybatis gets fake result when I want to get Generated Keys(batch insert with ignore)

Kazuki Shimizu
Sorry... my comment will withdraw...

On Sunday, April 29, 2018 at 7:07:41 PM UTC+9, Kazuki Shimizu wrote:
Does not support this case.

Please see closed issues related with this. See <a href="https://github.com/mybatis/mybatis-3/issues?q=is%3Aissue+batch+generated+is%3Aclosed" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmybatis%2Fmybatis-3%2Fissues%3Fq%3Dis%253Aissue%2Bbatch%2Bgenerated%2Bis%253Aclosed\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE049mjWNwMKDJWjJnI4lcVRadzeQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmybatis%2Fmybatis-3%2Fissues%3Fq%3Dis%253Aissue%2Bbatch%2Bgenerated%2Bis%253Aclosed\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE049mjWNwMKDJWjJnI4lcVRadzeQ&#39;;return true;">https://github.com/mybatis/mybatis-3/issues?q=is%3Aissue+batch+generated+is%3Aclosed .


On Sunday, April 29, 2018 at 6:57:57 PM UTC+9, 杨雨辰 wrote:
<insert id="batchRecord" parameterType="List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT IGNORE INTO user_info(
VALUES
<foreach collection="list" item="item" separator=",">
      #{item.username,jdbcType=VARCHAR}
</foreach>
</insert>

I want to get generated keys when i insert ingore to the table,but the result is not right. table of user_info has an unique key about username ,so it cannot be written to the table
if the table already has this record. 
using this method ,the result ge a fake result . generated key cannot match the certain record.

--
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: mybatis gets fake result when I want to get Generated Keys(batch insert with ignore)

杨雨辰
@

Kazuki Shimizu 

thank for your help at first ,while I still wonder hao to get a right resule when my table has an unique key .


Kazuki Shimizu <[hidden email]> 于2018年4月29日周日 下午6:21写道:
Sorry... my comment will withdraw...

On Sunday, April 29, 2018 at 7:07:41 PM UTC+9, Kazuki Shimizu wrote:
Does not support this case.



On Sunday, April 29, 2018 at 6:57:57 PM UTC+9, 杨雨辰 wrote:
<insert id="batchRecord" parameterType="List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT IGNORE INTO user_info(
VALUES
<foreach collection="list" item="item" separator=",">
      #{item.username,jdbcType=VARCHAR}
</foreach>
</insert>

I want to get generated keys when i insert ingore to the table,but the result is not right. table of user_info has an unique key about username ,so it cannot be written to the table
if the table already has this record. 
using this method ,the result ge a fake result . generated key cannot match the certain record.

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

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