[英]MyBatis return value after Insert
Hey guys i am new to MyBatis and trying to create an account from incoming request object, but when i try doing it it says:嘿伙计们,我是 MyBatis 的新手,并试图从传入的请求 object 创建一个帐户,但是当我尝试这样做时,它说:
Mapper method 'com.example.modular.mappers.AccountMapper.createAccount' has an unsupported return type: class com.example.modular.model.Account
Mapper:映射器:
public interface AccountMapper {
@Select("SELECT * FROM ACCOUNT WHERE id = #{id}")
Account getAccount(@Param("id") Long id);
@Options(useGeneratedKeys=true, keyProperty = "id", keyColumn="id")
@Insert("INSERT INTO ACCOUNT(customerId,country) values (#{customerId},#{country})")
Account createAccount(Account account);
Sql schema Regarding Schema i am not sure if first row where id specified i wrote correctly -> goal is for id to be auto incremented when new record gets inserted Sql 架构关于架构我不确定我指定的第一行是否正确地写了 id -> 目标是在插入新记录时自动递增 id
CREATE TABLE IF NOT EXISTS Account
(
id INTEGER NOT NULL GENERATED always as identity,
customerId INTEGER,
country VARCHAR(22)
);
Account model帐户 model
public class Account {
@Id
private Long id;
@Column("country")
private String country;
@Column("customerId")
private Long customerId;
}
You need to use below insert query您需要使用以下插入查询
@Insert("INSERT INTO ACCOUNT(customerId,country) values (#{account.customerId},#{account.country})")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.