jpa注解

系统生成uuid注解配置:

@Id

@GenericGenerator(name ="system-uuid", strategy ="uuid2")

@GeneratedValue(generator ="system-uuid")

@Column(name ="id",length =64)


一对多不产生外键关联关系,重点是foreignKey :

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)

@JoinColumn(name ="project_application_id", foreignKey =@ForeignKey(name ="none", value = ConstraintMode.NO_CONSTRAINT))


非外键关联配置,重点是referencedColumnName 指向关联表的字段

@ManyToOne(fetch = FetchType.LAZY)

@JoinColumn(name ="service_coupons_type", referencedColumnName ="service_coupons_type", foreignKey =@ForeignKey(name ="none", value = ConstraintMode.NO_CONSTRAINT))

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。