From 2696da8e4236f59df172bf667d9715969e6668a4 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Thu, 21 Aug 2025 16:20:34 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=8A=A0=E5=85=A5=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lanyuanxiaoyao/service/template/entity/Company.java | 4 ++++ .../lanyuanxiaoyao/service/template/entity/Employee.java | 7 +++++-- .../com/lanyuanxiaoyao/service/template/entity/Report.java | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/lanyuanxiaoyao/service/template/entity/Company.java b/src/test/java/com/lanyuanxiaoyao/service/template/entity/Company.java index b18db25..9f5aac9 100644 --- a/src/test/java/com/lanyuanxiaoyao/service/template/entity/Company.java +++ b/src/test/java/com/lanyuanxiaoyao/service/template/entity/Company.java @@ -10,7 +10,9 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.FieldNameConstants; import org.hibernate.annotations.Comment; +import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.SoftDelete; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Setter @@ -18,7 +20,9 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; @ToString(callSuper = true) @FieldNameConstants @Entity +@SoftDelete @DynamicUpdate +@DynamicInsert @EntityListeners(AuditingEntityListener.class) @Comment("企业") public class Company extends SimpleEntity { diff --git a/src/test/java/com/lanyuanxiaoyao/service/template/entity/Employee.java b/src/test/java/com/lanyuanxiaoyao/service/template/entity/Employee.java index 6722280..7eba730 100644 --- a/src/test/java/com/lanyuanxiaoyao/service/template/entity/Employee.java +++ b/src/test/java/com/lanyuanxiaoyao/service/template/entity/Employee.java @@ -6,7 +6,6 @@ import jakarta.persistence.Entity; import jakarta.persistence.EntityListeners; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; -import jakarta.persistence.FetchType; import jakarta.persistence.ForeignKey; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; @@ -17,7 +16,9 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.FieldNameConstants; import org.hibernate.annotations.Comment; +import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.SoftDelete; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Setter @@ -25,7 +26,9 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; @ToString(callSuper = true) @FieldNameConstants @Entity +@SoftDelete @DynamicUpdate +@DynamicInsert @EntityListeners(AuditingEntityListener.class) @NamedEntityGraph(name = "employee.detail", attributeNodes = { @NamedAttributeNode("company") @@ -43,7 +46,7 @@ public class Employee extends SimpleEntity { @Comment("角色") private Role role; - @ManyToOne(fetch = FetchType.LAZY) + @ManyToOne @JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @ToString.Exclude private Company company; diff --git a/src/test/java/com/lanyuanxiaoyao/service/template/entity/Report.java b/src/test/java/com/lanyuanxiaoyao/service/template/entity/Report.java index 50a7c50..2a28f4f 100644 --- a/src/test/java/com/lanyuanxiaoyao/service/template/entity/Report.java +++ b/src/test/java/com/lanyuanxiaoyao/service/template/entity/Report.java @@ -10,7 +10,9 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.FieldNameConstants; import org.hibernate.annotations.Comment; +import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.SoftDelete; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Setter @@ -18,7 +20,9 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; @ToString(callSuper = true) @FieldNameConstants @Entity +@SoftDelete @DynamicUpdate +@DynamicInsert @EntityListeners(AuditingEntityListener.class) @Comment("报告") public class Report extends SimpleEntity {