I have 2 tables "student" and "picklist".
picklist - used it as a general table for listing, as a state, country, city.
Here is the student class:
@Entity
public class Student {
@Id
Long id;
String firstName;
String lastName;
Long accountId;
@OneToOne(fetch=FetchType.EAGER)
@JoinColumns({@JoinColumn(name="country",referencedColumnName = "name"),
@JoinColumn(name="accountId",referencedColumnName = "accountId")}
)
PickList country;
@OneToOne(fetch=FetchType.EAGER)
@JoinColumns({@JoinColumn(name="state",referencedColumnName = "name"),
@JoinColumn(name="accountId",referencedColumnName = "accountId")}
)
PickList state;
}
Here is the selection table:
@Entity
@Table(name = "picklist", uniqueConstraints = {
@UniqueConstraint(columnNames = {"accountId", "name"})
})
public class PickList {
@Id
long id;
long accountId;
String name;
}
error -
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: column: accountid (should be mapped with insert="false" update="false")
source
share