Hi,
I got a mapping issue and I have no idea how to resolve this.
I created an object SeisSet.java:
Code:
@Entity
@Table(name="seis_set")
public class SeisSet implements Serializable
{
@Id
@Column(name = "seis_set_id")
private String seisSetId;
@ManyToOne
@JoinColumn(name="country", referencedColumnName="country")
private Country country;
@ManyToOne
@JoinColumns(
@JoinColumn(name="country", referencedColumnName="country"),
@JoinColumn(name="province_state", referencedColumnName="province_state")
)
private ProvinceState provinceState;
.......
}
There are two "ManyToOne" relationship in this entity. Their object:
Code:
@Entity
@Table(name="z_r_country")
@Embeddable
public class Country implements Serializable
{
@Id
@Column(name="country")
private String id;
@Column(name="long_name")
private String name;
.....
}
Code:
@Entity
@Table(name="z_r_province_state")
@Embeddable
public class ProvinceState implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
private ProvinceStatePK id;
@Column(name="long_name")
private String name;
@ManyToOne
@JoinColumn(name="country", insertable = false, updatable = false)
private Country country;
........
Code:
@Embeddable
public class ProvinceStatePK implements Serializable
{
private static final long serialVersionUID = 1L;
@Column(name = "country")
private String country;
@Column(name = "province_state")
private String provinceState;
.......
}
When I ran the code I got error:
Code:
Repeated column in mapping for entity: SeisSet column: country (should be mapped with insert="false" update="false")
But I cannot add
Code:
insert="false" update="false"
to the property "province_state" because this field will not be inserted/updated with the value when I inserted a province/state into the entity SeisSet.
Does anyone know how to handle this situation?