hibernate注解,带有继承manytone和mappedsuperclass

apeeds0o  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(298)

有火灾的麻烦。
两个实体的状态相同,但每个实体的状态描述不同:

我用这些类来描述它:

@Data
@MappedSuperclass
public class SimpleRecord {

    @Id
    @Column
    private int id;

    @Column
    private String name;
}
@Entity
@EqualsAndHashCode(callSuper = true)
@Inheritance(strategy = InheritanceType.JOINED)
public class OrgStatus extends SimpleRecord {
}
`
@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@PrimaryKeyJoinColumn(name = "id")
public class DeliveryOrgBranchStatus extends OrgStatus {
    @Column
    String description;
}
@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@PrimaryKeyJoinColumn(name = "id")
public class DeliveryOrgStatus extends OrgStatus {
    @Column
    String description;
}
@Entity
@Data
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
public class DeliveryOrgBranch {
    //....
    @ManyToOne
    @JoinColumn(name = "status")
    private DeliveryOrgBranchStatus status;
}
@Entity
@Data
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
public class DeliveryOrg {
    //....
    @ManyToOne
    @JoinColumn(name = "status")
    private DeliveryOrgStatus status;
}

我试过很多东西,但都不管用。在当前版本中,出现以下错误:

Object [id=1] was not of the specified subclass [DeliveryOrgBranchStatus]: 
loaded object was of wrong class class DeliveryOrgStatus

请帮帮我!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题