我的实体看起来像
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"id", "service_version_id"}))
public class MarketVersion extends AbstractVersion<MarketVersion> {
@ManyToOne(cascade = CascadeType.ALL)
private Market market;
@OneToOne
private MarketVersion parentVersion;
@OneToMany(cascade = CascadeType.MERGE)
@JoinColumn(name = "services_id", referencedColumnName = "id")
private List<ServiceVersion> services;
}
和服务看起来像
public class ServiceVersion extends AbstractVersion<ServiceVersion> {
@ManyToOne(cascade = CascadeType.ALL)
private Service service;
@OneToOne
private ServiceVersion parentVersion;
@Column
private String description;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private ServiceImplementations implementation;
}
当我运行它时,我看到
[hibernatetool] javax.persistence.PersistenceException: [PersistenceUnit: market] Unable to configure EntityManagerFactory
[hibernatetool] org.hibernate.AnnotationException: Unable to create unique key constraint (id, service_version_id) on table MarketVersion: service_version_id not found
我肯定是新手,我做的不对,但无法理解,请指教
我想要一个对唯一(market_version_id 和 service_version_id)有约束的新表