我最近从 hibernate-core 4.1.7 升级到 5.0.9 并且对这段代码有问题:
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@JoinColumn(name = "FK_AAA", foreignKey = @ForeignKey(name = "CS_BBB"))
@org.hibernate.annotations.Index(name = "IDX_CCC", columnNames = "FK_DDD")
private ImportData importData;
这会生成指向定义类的正确外部列,但也会在同一类上生成一列:
IMPORTDATA RAW(255)
为什么会生成这个 raw(255) 列?我认为它不是用 Hibernate-core 4.1.7 生成的
任何的想法 ?
更新 1:这里是更长的代码片段:
@MappedSuperclass
@Access(AccessType.PROPERTY)
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public abstract Long getId();
}
@Entity
@Table(name = "IMPORT_DATA", uniqueConstraints = {
@UniqueConstraint(name = "UC_IMP_BID", columnNames = {"BUSINESS_ID"})
}, indexes = {
@Index(name = "IDX_IMP_DGXML_ID", columnList = "FK_DGXML_ID"),
@Index(name = "IDX_IMP_IMPXML_ID", columnList = "FK_IMPXML_ID")
})
public class ImportData extends BaseEntity {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() { return id; }
// ...
}
@Entity(name = "MUTATION")
@Table(name = "MUTATION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@SequenceGenerator(name = "mutationsSeq", sequenceName = "MUTATIONS_SEQUENCE", allocationSize = 1)
public abstract class Mutation extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "mutationsSeq")
private Long id;
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@JoinColumn(name = "FK_IMP_ID", foreignKey = @ForeignKey(name = "CS_MUT_IMP_ID"))
@org.hibernate.annotations.Index(name = "IDX_MUT_IMP_ID", columnNames = "FK_IMP_ID")
protected ImportData importData;
}
@Entity(name="XXX")
@DiscriminatorValue("XXX_DISC")
public class XXX extends Mutation {
// ...
}