![](/img/trans.png)
[英]How to return multiple generated columns after insert in MyBatis(Oracle)
[英]MyBatis return value after Insert
嘿伙計們,我是 MyBatis 的新手,並試圖從傳入的請求 object 創建一個帳戶,但是當我嘗試這樣做時,它說:
Mapper method 'com.example.modular.mappers.AccountMapper.createAccount' has an unsupported return type: class com.example.modular.model.Account
映射器:
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 架構關於架構我不確定我指定的第一行是否正確地寫了 id -> 目標是在插入新記錄時自動遞增 id
CREATE TABLE IF NOT EXISTS Account
(
id INTEGER NOT NULL GENERATED always as identity,
customerId INTEGER,
country VARCHAR(22)
);
帳戶 model
public class Account {
@Id
private Long id;
@Column("country")
private String country;
@Column("customerId")
private Long customerId;
}
您需要使用以下插入查詢
@Insert("INSERT INTO ACCOUNT(customerId,country) values (#{account.customerId},#{account.country})")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.