我将这个实体定义用于JPA:
@Entity
@Table(name = "payment_transactions")
public class PaymentTransactions implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, updatable = false, nullable = false)
private int id;
@Column
private Date date;
@Column
private Integer year;
.....
}
表已成功创建:
CREATE TABLE `payment_transactions` (
`id` int(11) NOT NULL,
....
PRIMARY KEY (`id`),
}
表已成功创建。
但是我希望MariaDB自动生成唯一的表键值。像这样:
CREATE TABLE `payment_transactions` (
`id` int(11) NOT NULL auto_increment,
....
PRIMARY KEY (`id`),
}
使用JPA进行配置的正确方法是什么?