gpt4 book ai didi

java - JpaSystemException - 无法设置字段值 [auditEntity] 扩展扩展实体

转载 作者:行者123 更新时间:2023-12-01 17:57:08 25 4
gpt4 key购买 nike

我有实体的自定义库-auditBase。有一个带有@MappedSuperclass、@EntityListener 和@RevisionEntity 的类。

    @RevisionEntity
@MappedSuperclass
@EntityListeners({AuditListener.class})
public class AuditBase {
@Column(
name = "client_app_id"
)
private String audit_clientAppId;
@Column(
name = "company_id"
)
private Long audit_companyId;
@Column(
name = "insert_date"
)...

在当前项目中,有一个名为“area”的实体。该实体是@MappedSuperclass

@Entity
@Table(name = "area")
@Inheritance(strategy = InheritanceType.JOINED)
@Getter
@Setter
public class AreaEntity extends AuditBase {

@Id
@SequenceGenerator(name = "area", sequenceName = "area", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "area")
@Column(name = "area")
private Long id;

@Column(name = "json_in_out_afp", columnDefinition = "TEXT")
private String jsonInOutAfp;

@Column(name = "afp_external_id", nullable = false, unique = true)
private Integer afpExternalId;

@Column(name = "area_status", length = 8, nullable = false)
private String areaStatus;...

另外两个实体扩展了 AreaEntity:

    @Entity
@Table(name = "place")
@Getter
@Setter
public class PlaceEntity extends AreaEntity implements Serializable {

@Column(name = "kind_of_place", nullable = false, length = 8)
private String kindOfPlace;

@Column(name = "measurement", nullable = false)
private boolean measurement;

@Column(name = "place_shape_type", nullable = false, length = 8)
private String placeShapeType;

@ManyToOne(targetEntity = PlaceSubAreaEntity.class)
@JoinColumn(name = "fk_place_sub_area", insertable = true, updatable = true)
private PlaceSubAreaEntity placeSubAreaEntity;...

与 PlaceEntity 相关的最后一个实体:

@Entity
@Table(name = "parking_place_sub_area")
@Getter
@Setter
public class PlaceSubAreaEntity extends AreaEntity implements Serializable {

@OneToMany
private Set<PlaceEntity> placeEntities = new HashSet<>();...

我有一个简单的查询 JpaRepository

@Repository
public interface PlaceRepository extends JpaRepository<PlaceEntity, Long> {

@Query("select place from PlaceEntity place where place.afpExternalId = :afpExternalId")
PlaceEntity findByAfpExternalId(@Param("afpExternalId") Integer afpExternalId);

使用后我遇到这样的异常:

org.springframework.orm.jpa.JpaSystemException: Could not set field value [AuditBase(audit_clientAppId=null, audit_companyId=null, audit_insertDate=null, audit_insertedBy=null, audit_updateDate=null, audit_updatedBy=null, audit_updateClientAppId=null, audit_operatorId=null, audit_app=null, audit_appNo=null, audit_appResNo=null, audit_appVer=null, audit_appTraceId=null, audit_appSpanId=null)] value by reflection : [class PlaceEntity.placeSubAreaEntity] setter of PlaceEntity.placeSubAreaEntity; nested exception is org.hibernate.PropertyAccessException: Could not set field value [AuditBase(audit_clientAppId=null, audit_companyId=null, audit_insertDate=null, audit_insertedBy=null, audit_updateDate=null, audit_updatedBy=null, audit_updateClientAppId=null, audit_operatorId=null, audit_app=null, audit_appNo=null, audit_appResNo=null, audit_appVer=null, audit_appTraceId=null, audit_appSpanId=null)] value by reflection : [class PlaceEntity.placeSubAreaEntity] setter of PlaceEntity.placeSubAreaEntity

我不知道如何解决这个问题。有人可以帮忙吗?

最佳答案

在本例中,我使用了鉴别器列。它解决了我的问题。

关于java - JpaSystemException - 无法设置字段值 [auditEntity] 扩展扩展实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60695008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com