useGeneratedKeys=true seems not working properly with sybase ase 15.7

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

useGeneratedKeys=true seems not working properly with sybase ase 15.7

yaowei19851218

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:

<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>
then will get the exception
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.
is any one metioned with this issue? any response will be very appreciated, thanks.
about the details you could also refer to https://github.com/mybatis/mybatis-3/issues/1183

--
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.
Tim
Reply | Threaded
Open this post in threaded view
|

Re: useGeneratedKeys=true seems not working properly with sybase ase 15.7

Tim
Hi try using:
<insert id="test" parameterType="bean.Test" useGeneratedKeys="true" keyProperty="id" keyColumn="id">


On Thu, Feb 1, 2018 at 8:46 PM, <[hidden email]> wrote:

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:

<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>
then will get the exception
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.
is any one metioned with this issue? any response will be very appreciated, thanks.
about the details you could also refer to https://github.com/mybatis/mybatis-3/issues/1183

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