@OneToMany
我在使用注释从一个类中引用另一个类中的复合主键时遇到问题。
我的复合主键类如下:
@Entity
@Table(name = "name_entry")
public class NameEntry {,
@EmbeddedId
private NameEntryPK id;
//getters, setters
}
Composite Id 类是这样的:
@Embeddable
public class NameEntryPK implements Serializable {
@Column(name = "entry")
protected String entry;
@Column(name = "name")
protected String name;
//getters, setters
}
这对我来说很清楚,它的工作很完美。问题发生在另一个地方。我想有另一个具有NameEntry
主键外键的类。我写过这样的东西:
@Entity
@Table(name = "content_entry")
public class ContentEntry {
//id, other columns
@OneToOne
@JoinColumns ({
@JoinColumn(name = "entry_content", referencedColumnName = "entry", insertable = false, updatable = false),
@JoinColumn(name="title_name", referencedColumnName = "name", insertable = false, updatable = false)
})
protected NameEntry nameEntry;
//getters, setters
}
据此,我的例外是:
Invocation of init method failed; nested exception is org.hibernate.MappingException:
Unable to find column with logical name: `entry` in
org.hibernate.mapping.Table(name_entry) and its related supertables and
secondary tables
据此:https ://hibernate.onjira.com/browse/HHH-7713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel我试图用给定的重音包围列名称。但它不起作用。