![](/img/trans.png)
[英]Caused by: org.hibernate.MappingException: Could not determine type for:
[英]Caused by: org.hibernate.MappingException: Could not determine type for
我有一個JPA Entity
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "name", "market_version" }))
public class Market extends MutableEntity {
@Column(nullable = false)
private String name;
@Column
private String description;
@Column(name = "market_version", nullable = false)
private Version marketVersion;
public Market(final String name, final String description) {
this.name = name;
this.description = description;
this.marketVersion = new Version("1.0", VersionType.MAJOR, VersionStatus.ACTIVE);
} ... snipped
其中包含一個Version
和Version
類看起來像
public class Version {
private String name;
private VersionType type;
private VersionStatus status;
private DateTime publishedOn;
private DateTime retiredOn;
private Version parentVersion;
public Version(@Nonnull final String name, @Nonnull final VersionType type, @Nonnull final VersionStatus status) {
this.name = name;
this.type = type;
this.status = status;
}
}
enum VersionType {
MAJOR,
MINOR,
BOTH
}
enum VersionStatus {
ACTIVE,
RETIRED
}
當我嘗試保存測試中的market
實體時,
@Test
public void testMarket() {
final Market market = new Market("test", "test market");
final MarketCrudService crudService = new MarketCrudService(jpaRule.getEntityManager());
crudService.create(market);
}
我看到錯誤
Caused by: org.hibernate.MappingException: Could not determine type for: com.myorg.project.versioning.entities.Version, at table: Market, for columns: [org.hibernate.mapping.Column(market_version)]
這到底是什么問題? 我該如何解決?
您必須像對待Market一樣,使Version帶有其自己的表成為完整實體,或者如果要將其保存為Market的一部分,則應使用@Embeddable注釋使其可嵌入。
如果使其可嵌入,則必須從Market的marketVersion字段中刪除@Column批注。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.