【发布时间】:2012-03-31 02:22:51
【问题描述】:
我的代码有问题(很明显),在 Internet 上进行多次搜索后,我没有找到问题的答案,所以我在这里提出我的问题。 我有这个:
@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 类中有一个 Entity 对象,但我不知道如何解决它
【问题讨论】: