I m able to get values using JPA when i have only mapped one table
Now when i have gone for mapping related tables i get the error
Only one may be defined as writable, all others must be specified read-only.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[userId1]
I m using [EclipseLink-0] (Eclipse Persistence Services – 2.0.1.v20100213-r6600)
In one of the child tables i have this code
@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;
What changes i have to do in this code to make the fields read-only?
or are there any better workaround for not making these fields read only?
You have two ManyToOne relationships using the same foreign key field. This does not make sense, they will be the same object?
You should have two different foreign key fields, i.e. albumImage and albumImage1.