Good afternoon. I have a problem and I've tried a lot of code before coming, but without success. Here's the problem: I have a class that has several attributes and methods:
public class Um
private tipo campo1;
private tipo campo2;
.
.
@JsonManagedReference
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "classeum_classedois", joinColumns = @JoinColumn(name = "fk_classeum"),inverseJoinColumns = @JoinColumn(name = "fk_classedois"))
private List<ClasseDois> campoListasClasseDois = new ArrayList<>();
The attribute "ClassListString" has a ManytoMany relationship for class Two:
public class Dois
private tipo campo1;
private tipo campo2;
.
.
@JsonBackReference
@ManyToMany(mappedBy = "campoListasClasseDois")
private List<ClasseUm> campoListasClasseDois = new ArrayList<>();
To insert, I did this:
Um classeUm = new Um('parametro1', 'parametro2', ... 'parametro do List classeDois');
Dois classeDois = new Dois('parametro1, 'parametro2'... 'parametro do List classeUM);
and finally:
classeUm.getParametrodaList.addALL(Arrays.asList(classeDois);
classeDois.getParametroList.addALL(Arrays.asList(classeUm);
The problem is that in my form on the web, the amount of the class Two is varied, where the customer is adding an amount that he wants. And I do not know how to persist more than one value. Because like I did, it only persists one class Two at a time, and I would like it to add several at a time. Could someone help me?