【发布时间】:2010-08-26 05:01:12
【问题描述】:
当我只映射一个表时,我可以使用 JPA 获取值
现在当我去映射相关表时,我得到了错误
Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[userId1]
我正在使用 [EclipseLink-0] (Eclipse Persistence Services - 2.0.1.v20100213-r6600)
在其中一个子表中我有这个代码
@OneToMany(cascade = CascadeType.ALL, mappedBy = "albumId")
private Collection<Images> imagesCollection;
@JoinColumn(name = "user_id", referencedColumnName = "User_ID")
@ManyToOne(optional = false)
private Roleuser userId;
@JoinColumn(name = "album_image", referencedColumnName = "image_id")
@ManyToOne
private Images albumImage;
@JoinColumn(name = "album_image", referencedColumnName = "image_id")
@ManyToOne
private Images albumImage1;
@JoinColumn(name = "user_id", referencedColumnName = "User_ID")
@ManyToOne(optional = false)
private Roleuser userId1;
我必须在此代码中进行哪些更改才能使字段为只读?
或者有没有更好的解决方法来不将这些字段设为只读?
【问题讨论】:
标签: java orm jpa entity-relationship eclipselink