1. 主要是注解@Options起作用,语句如下:
@Insert({
"INSERT INTO application_open_up ( " +
"app_open_hospital_id, " +
"application_id, " +
"service_time, " +
"createdby, " +
"createdon, " +
"modifiedby, " +
"modifiedon, " +
"deletion_state, " +
"purchase_price, " +
"config_id, " +
"meta_url " +
") " +
"VALUES (" +
"#{appOpenHospitalId}, " +
"#{applicationId}, " +
"#{serviceTime}, " +
"#{createby}, " +
"#{createon}, " +
"#{modifiedby}, " +
"#{modifiedon}, " +
"#{deletionState}, " +
"#{purchasePrice}, " +
"#{configId}, " +
"#{metaUrl}) "})
@Options(useGeneratedKeys = true, keyProperty = "id")
void save(PApplicationOpenUp pApplicationOpenUp);
2. 另一种形式,在实体类的主键上加上注解: @Id 与 @GeneratedValue(generator = "JDBC"),如下所示:
@Id
@ApiModelProperty(value = "自增主键")
@Column(name = "interface_regular_id")
@GeneratedValue(generator = "JDBC")
private Integer interfaceRegularId;