美文网首页
JPA建表注解总结

JPA建表注解总结

作者: wxyjj | 来源:发表于2019-11-21 11:31 被阅读0次

@Entity
@Table(name = "gftech_health_raise_user_device_alarm",uniqueConstraints = {@UniqueConstraint(columnNames = {"deal_content"})})
@org.hibernate.annotations.Table(appliesTo = "gftech_health_raise_user_device_alarm",comment = "用户设备告警详细处理关联表")
@GenericGenerator(name = "uuid",strategy = "uuid")
@Data
public class UserDeviceAlarm implements Serializable {

private static final long serialVersionUID = 5959374129855800499L;
@Id
@GeneratedValue(generator = "uuid")
@Column(name = "id",columnDefinition = "varchar(50) comment '主键id'")
private String id;
@Column(name = "deal_user_id", columnDefinition = "varchar(255) comment '处理人id'")
private String dealUserId;
@Column(name = "deal_time",columnDefinition = "datetime(3) comment '处理时间'")
private Date dealTime;
@Column(name = "deal_content",nullable = false,columnDefinition = "varchar(255) comment '处理反馈内容'")
private String dealContent;
}

思维导图


image.png

建议:
最好不要将字段长度、字段精度、字段保留几位的属性等在@Column中用length = ,precision = ,scale =来定义。推荐使用columnDefinition =,属性(DDL)来规划一个字段的长度或精度或类型来定义。

相关文章

网友评论

      本文标题:JPA建表注解总结

      本文链接:https://www.haomeiwen.com/subject/xewzictx.html