大家好,我是MyBatis的新手,正尝试从传入的请求对象创建帐户,但是当我尝试这样做时,它说:
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)
);
帐户模型
public class Account {
@Id
private Long id;
@Column("country")
private String country;
@Column("customerId")
private Long customerId;
}
答案 0 :(得分:0)
您需要在下面使用插入查询
@Insert("INSERT INTO ACCOUNT(customerId,country) values (#{account.customerId},#{account.country})")