public
class
TestTable
implements
Serializable {
private
static
final
long
serialVersionUID = 1L
;
@GeneratedValue(strategy
=
GenerationType.IDENTITY)
@Column(name
= "id", columnDefinition = "BIGINT"
)
private
Long id;
@Column(name
= "user_name", columnDefinition = "varchar(50) NOT NULL COMMENT '用户名称'"
)
private
String userName;
@Column(name
= "address", columnDefinition = "varchar(50) NOT NULL COMMENT '用户地址'"
)
private
String address;
@Column(name
= "sex", columnDefinition = "tinyint
NOT NULL DEFAULT 0 COMMENT '性别:0-男 1-女'
"
)
private
Integer sex;
public
class
TestTable
implements
Serializable {
private
static
final
long
serialVersionUID = 1L
;
@GeneratedValue(strategy
=
GenerationType.IDENTITY)
@Column(name
= "id", columnDefinition = "BIGINT"
)
private
Long id;
@Column(name
= "user_name", columnDefinition = "varchar(50) NOT NULL COMMENT '用户名称'"
)
private
String userName;
@Column(name
= "address", columnDefinition = "varchar(50) NOT NULL COMMENT '用户地址'"
)
private
String address;
@Column(name
= "sex", columnDefinition = "tinyint NOT NULL'")
private Integer sex = 0
;
建议:使用方法二
记录意义:在数据库设置时间类型时,有的使用timestamp ,有的使用datetime,个人推荐使用datetime
@Entity
@Table(name = "m_test")
public class TestTable implements Serializable {
private static final long serialVersionUID = 1L;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", columnDefinition = "BIGINT")
private Long id;
@Column(name = "user_name", columnDefinition = "varchar(50) NOT NULL COMMENT '用户名称'")
private String userName;
@Column(name = "address", columnDefinition = "varchar(50) NOT NULL COMMENT '用户地址'")
private String address;
@Column(name = "sex", columnDefinition = "tinyint NOT NULL'")
private Integer sex = 0;
@JsonFormat
@Column(name = "cdate", columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP ")
private LocalDateTime cdate = LocalDateTime.now();
@JsonFormat
@Column(name = "mdate", columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP ")
private LocalDateTime mdate = LocalDateTime.now();