-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Description
MyBatis version
3.4.5
Database vendor and version
1> select @@version
2> go
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Adaptive Server Enterprise/15.7/EBF 25127 SMP SP136 /P/x86_64/Enterprise Linux/ase157sp136x/3955/64-bit/FBO/Mon Oct 19 19:12:00 2015
Test case or example project
1> create table test(tid int identity not null, tname varchar(30) null)
2> go
Mapper:
public interface TestMapper {
void test(Test t);
}junit test case
@Test
public void gg(){
bean.Test t = new bean.Test();
t.setName("abcd");
mapper.test(t);
}bean:
public class Test {
private int id;
private String name;
public Test(){}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="bean.TestMapper">
<resultMap type="bean.Test" id="testmap">
<id property="id" column="ID" />
<result property="name" column="NAME" />
</resultMap>
<insert id="test" parameterType="bean.Test" useGeneratedKeys="true">
insert into test values(#{name})
</insert>
</mapper>Steps to reproduce
run test case
Expected result
get the generated id in test.id
Actual result
Caused by: java.sql.SQLException: JZ0NK: Generated keys are not available because either the Statement.NO_GENERATED_KEYS was used or no keys were automatically generated.
Metadata
Metadata
Assignees
Labels
No labels