我在MappedSuperClass中有一个Field,它使用@Column进行了分配,但该字段的类型不是由Hibernate决定的。
类
@Getter
@Setter
@MappedSuperClass
public abstract class IdentifiableObject {
@Id
@GeneratedValue
private Integer id;
}
@Getter
@Setter
@MappedSuperClass
public abstract class EvaluationPeriodObject extends IdentifiableObject{
@Column
private Period period;
}
@Data
@Entity
@Table(name = "PERIOD")
public class Period extends IdentifiableObject {
@Column
private LocalDate start;
@Column
private LocalDate end;
}
@Data
@Entity
@Table(name = MY_CLASS, indexes = {
@Index(name = "FK_MY_CLASS_PERIOD", columnList = "PERIOD")
})
public class MyClass extends EvaluationPeriodObject {
@Column
private String description;
}
Caused by: org.hibernate.MappingException: Could not determine type for: Period, at table: MY_CLASS, for columns: [org.hibernate.mapping.Column(period)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:455)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:422)
at org.hibernate.mapping.Property.isValid(Property.java:226)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:597)
at org.hibernate.mapping.RootClass.validate(RootClass.java:265)
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:459)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
... 45 more
Hibernate版本:compile 'org.hibernate:hibernate-core:5.2.13.Final'
SpringBoot版本2.0.0.RELEASE
如果需要更多信息,请与我们联系。
我一直在阅读关于此的大部分帖子,但形成了我读过的内容,他们主要使用“Getters”和“Fields”上的注释来吸引人们,因为我使用的是Lombok我没有任何Getters来放置因此我认为这不是我面临的问题。
答案 0 :(得分:0)
请尝试将AccessType.FIELD添加到getter和setter注释@Getter(AccessType.FIELD)
。