Hi,
I am working with ManyToMany annotation and I cannot obtain the behaviour I'd like to. I need for this forum's help.
I have these tables:
SkillTypes:
id_skill_type
...
Operations:
id_operation
...
R_operations_skills:
id_r_operation_skill PK
id_operation FK
id_skill_type FK
In my 2 entity beans (I don't have a EJB for the relation table R_operations_skills) I used these annotations:
Operation.java
@ManyToMany(cascade={CascadeType.REFRESH, CascadeType.PERSIST}, fetch=FetchType.LAZY) @JoinTable(name="r_operations_skills", joinColumns=@JoinColumn(name="id_operation"), inverseJoinColumns=@JoinColumn(name="id_skill_type")) @OrderBy("description") public List<SkillType> getSkillTypes() { return skillTypes; }
@ManyToMany(cascade={CascadeType.REFRESH, CascadeType.PERSIST}, fetch=FetchType.LAZY) @JoinTable(name="r_operations_skills", joinColumns=@JoinColumn(name="id_skill_type"), inverseJoinColumns=@JoinColumn(name="id_operation")) @OrderBy("description") public List<Operation> getOperations() { if(operations == null) { operations = new ArrayList<Operation>(); } return this.operations; }