我的代码有问题(很明显),并且在互联网上进行了很多搜索之后,我没有找到我的问题的答案,所以我在这里问我的问题。 我有这样的:JPA - EmbeddedId with @ManytoOne
@Entity
public class Resident
{
/** Attributes */
@EmbeddedId
private IdResident idResident;
...
@Embeddable
public class IdResident {
@Column(name="NOM")
private String nom;
@ManyToOne
@JoinColumn(name="CODE")
private Port port;
...
@Entity
public class Port
{
/** Attributes */
@Id
@Column(name="CODE")
private String code;
@Column(name="NOM")
private String nom;
...
而且我使用Maven,我在我的persistence.xml这样写:
<class>beans.Port</class>
<class>beans.Resident</class>
但是当我运行该程序,不管是什么,我写,我有这样的:
Exception Description: The mapping [port] from the embedded ID class
[class beans.IdResident] is an invalid mapping for this class. An embeddable class that
is used with an embedded ID specification (attribute [idResident] from the source
[class beans.Resident]) can only contain basic mappings. Either remove the non
basic mapping or change the embedded ID specification on the source to be embedded.
我看不出哪里是我的错误,我想这是因为IdResident类至极的中有一个实体对象,但我不知道该怎么FIW它