I have the following (simplified) situation:
Fields for TABLE A:
Fields for TABLE AB:
Fields for TABLE B:
and want to map it with entities using a OneToMany like this (in the master class mapped on table A):
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = false, fetch = FetchType.LAZY)
@JoinTable(name = "AB",
joinColumns= {
@JoinColumn(name = "AID", referencedColumnName="ID"),
@JoinColumn(name = "COMMONID", referencedColumnName="COMMONID")},
inverseJoinColumns = {
@JoinColumn(name = "BID", referencedColumnName="ID"),
@JoinColumn(name = "COMMONID", referencedColumnName="COMMONID")})
private Set<MyClassForB> list= new HashSet<MyClassForB>();
Building the session, I obtain the following error:
org.hibernate.MappingException: Repeated column in mapping for collection using @JoinTable list column: COMMONID
What am I doing wrong? Consider that I'm new to Hibernate.
Try to add insertable, and updateable like this
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = false, fetch = FetchType.LAZY)
@JoinTable(name = "AB",
joinColumns= {
@JoinColumn(name = "AID", referencedColumnName="ID", insertable = false, updatable = false),
@JoinColumn(name = "COMMONID", referencedColumnName="COMMONID", insertable = false, updatable = false)},
inverseJoinColumns = {
@JoinColumn(name = "BID", referencedColumnName="ID", insertable = false, updatable = false),
@JoinColumn(name = "COMMONID", referencedColumnName="COMMONID", insertable = false, updatable = false)})
private Set<MyClassForB> list= new HashSet<MyClassForB>();
But I'm not sure whether you will able to update this set, my use case was read only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With