我的類看起來像JPA:如何創建與實體相同類型的字段?
@Entity
public class Version extends MutableEntity {
@Column(nullable = false)
private String name;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private VersionType type;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private VersionStatus status;
@Column(nullable = true)
private DateTime publishedOn;
@Column(nullable = true)
private DateTime retiredOn;
@Column
private Version parentVersion;
我想有相同類型的parentVersion
作爲Version
,但我的測試失敗
@Test
public void testVersion() {
Version version = new Version("testVersion", VersionType.MAJOR);
version = crudService.create(version);
assertNotNull(version.getId());
}
,我看到錯誤的
Caused by: org.hibernate.MappingException: Could not determine type for: com.myorg.project.versioning.entities.Version, at table: Version, for columns: [org.hibernate.mapping.Column(parentVersion)]
哪有我解決了這個問題?