Seam-gen as in version 2.0 doesn't still manage many to many db relationship.
I post here the modifications we made to our code and xhtml files to manage the manytomany db relationship in our application, maybe it can be useful to others having the same needs.
We have a class named Prodotto which has a unidirectional manytomany relationship with a class named Componente.
We had to modify the following files:
ProdottoHome.java (see attachment)
ProdottoEdit.xhtml (see attachment)
In ProdottoEdit.xhtml in the subview we added the button "Add componente" add a relationship in the Prodotto with a Componente.
We also added a DeleteAll button to delete the relationships in the Prodotto to all the Componentes.
The next step would be to delete a single relationship selectively.
In ProdottoHome.java instead we have:
The wire() method is where we add the selected Componente to the Componentes relationship list.
The getComponentes() method is the same as in the code generated by seam-gen in the onetomany relationship.
We added the method removeComponents() that is the one called by the DeleteAll button in ProdottoEdit.xhtml
Comments