I have a many to many relationship at my Java beans. When I use List
to define my variables as like:
@Entity
@Table(name="ScD")
public class Group extends Nameable {
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
@JoinColumn(name="b_fk")
private List<R> r;
//or
private Set<R> r;
I get that error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'
...
When I use Set
everything seem to work well.
I want to ask that when using many to many relationships which one to use for logical consept List
or Set
(because of list may have duplicates and set but what about performance and other issues)?