Hi buddies. I have a following problem that I need to solve. The core issues is that I want to add additional column into JoinTable for ManyToMany relation in JPA. In my case I have following entities.
The Topic is a simple entity which has many RemoteDocument's (one RemoteDocument may be refered by many Topic's, hence it should be ManyToMany relation). Also RemoteDocument entity is read only because it may be read only from Oracle Materialized View moreover any altering of this Materialized View is forbidden. So I want to store order of RemoteDocuments related to some Topic. In fact I can do something like that with additional entity:
@Entity
public class Topic {
@Id
private Long id;
@Basic
private String name;
@OneToMany
private Set<TopicToRemoteDocument> association;
}
@Entity
public class RemoteDocument {
@Id
private Long id;
@Basic
private String description;
}
@Entity
public class TopicToRemoteDocument {
@OneToOne
private Topic topic;
@OneToOne
private RemoteDocument remoteDocument;
@Basic
private Integer order;
}
In this case additional entity TopicToRemoteDocument helps me to replace ManyToMany association with OneToMany and add extra field order.
But I want to have ManyToMany relation but with configured additional column in join table