1. 程式人生 > >jpa實現mysql的主鍵自增

jpa實現mysql的主鍵自增

在實體的主鍵上添加註解 @GeneratedValue(strategy=GenerationType.IDENTITY)

@Entity
@Table(name = "OPERATION_LOG")
public class test implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "operation_id")
    private Long operationid;
}