[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Mapping Question - OneToMany Create Table from Entity Fails
|
Hello,
As the error states, the CCFParameter.id database field is mapped
twice. Notice that CCFParameter's id and ccfgroup both use the "id"
field - one of them will need to be set as insertable=false
updateable=false.
Best Regards,
Chris
RogerV wrote:
I've got the following entity definitions (trimmed) below. When I try to
generate Tables from Entities I get the error message;
Exception [EclipseLink-48] (Eclipse Persistence Services -
1.1.2.v20090612-r4475):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Multiple writable mappings exist for the field
[CCFParameter.id]. Only one may be defined as writable, all others must be
specified read-only.
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[ccfgroup]
Descriptor: RelationalDescriptor(com.blackbox.entities.db.CCFParameter -->
[DatabaseTable(CCFParameter)])
What do I need to correct this and what does it actually mean?
Regards
@Entity
@Table(name="CCFGroup")
public class CCFGroup {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
//bi-directional many-to-one association to CCFParameter
@OneToMany(mappedBy="ccfgroup",fetch=FetchType.LAZY,
cascade={CascadeType.ALL})
private Set<CCFParameter> ccfParameters;
public CCFGroup() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public Set<CCFParameter> getCcfParameters() {
return this.ccfParameters;
}
public void setCcfParameters(Set<CCFParameter> ccfParameters) {
this.ccfParameters = ccfParameters;
}
}
@Entity
@Table(name="CCFParameter")
public class CCFParameter implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="description", nullable=false, length=128)
private String description;
@Column(name="idsDescription", nullable=false, length=128)
private String idsDescription;
@Column(name="parameterName", unique=true, nullable=false, length=64)
private String parameterName;
@ManyToOne (cascade=CascadeType.ALL)
@JoinColumn(name="id")
private CCFGroup ccfgroup;
@Version
@Column(name="version", nullable=false)
private long version;
@Column(name="display", nullable=false, length=1)
private String display;
public CCFParameter() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public CCFGroup getCCFGroup() {
return ccfgroup;
}
public void setCCFGroup(CCFGroup ccfgroup) {
this.ccfgroup = ccfgroup;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIdsDescription() {
return this.idsDescription;
}
public void setIdsDescription(String idsDescription) {
this.idsDescription = idsDescription;
}
public String getParameterName() {
return this.parameterName;
}
public void setParameterName(String parameterName) {
this.parameterName = parameterName;
}
public long getVersion() {
return this.version;
}
public void setVersion(long version) {
this.version = version;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}