Table JPAContainer with info obtained by Hibernate

Hi everyone!

I’m a new developer of vaadin and I’m having a lot of problems with this framework. I am in a project with vaadin+Spring+Hibernate with an Oracle database. I’ve developed a simple example with two domains, User and Context, the relationship between them are Many to Many and my domains are like these:

[code]
@Entity
@Table(name = “SAT20_USERS”)
public class Users {
private Long user_id;
private Long niu;
private String nom;
private String admin;
private String mail;
private Set contexts = new HashSet(0);


@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = “SAT20_USER_CTX”, joinColumns = { @JoinColumn(name = “USER_ID”, nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = “CTXT_ID”, nullable = false, updatable = false) })
public Set getContexts() {
return contexts;
}
public void setContexts(Set contexts) {
this.contexts = contexts;
}
}
[/code]and

[code]
@Entity
@Table(name = “SAT20_CTXT”)
public class Context {

private Long id;
private String name;
private Area area;
private String code;
private Set<Users> users = new HashSet<Users>(0);

@Id
@GeneratedValue(strategy=GenerationType.AUTO,generator="context_generator")
@SequenceGenerator(name="context_generator", sequenceName="SAT20_SQ_CTXT")
@Column(name = "CTXT_ID", unique = true, nullable = false)
public Long getId() {
    return id;
}
....

@ManyToMany(fetch = FetchType.LAZY, mappedBy = "contexts")
public Set<Users> getUsers() {
    return this.users;
}

}
[/code]As you can see exists an intermediate table called “SAT20_USER_CTX” to connect “SAT20_CTX” and “SAT20_USER” (for simulate Many to Many relationship). My problem is that when I try to print a table with all the users I have an error in line: table_1.setContainerDataSource(persons);

com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update The way that I try to print the User list is this:

public class UserManagement extends CustomComponent {
    
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private VerticalLayout verticalLayout_3;

    @AutoGenerated
    private VerticalLayout verticalLayout_2;

    @AutoGenerated
    private GridLayout gridLayout_2;

    @AutoGenerated
    private CheckBox checkBox_admin;

    @AutoGenerated
    private Label label_admin;

    @AutoGenerated
    private Label label_mail_resultat;

    @AutoGenerated
    private Label label_mail;

    @AutoGenerated
    private Label label_nom_resultat;

    @AutoGenerated
    private Label label_nom;

    @AutoGenerated
    private TextField textField_1;

    @AutoGenerated
    private Label label_NIU;

    @AutoGenerated
    private HorizontalLayout horizontalLayout_1;

    @AutoGenerated
    private Button button_elimina;

    @AutoGenerated
    private Button button_guardar;

    @AutoGenerated
    private Button button_nou;

    @AutoGenerated
    private Table table_1;

    private final Logger log=Logger.getLogger(this.getClass().getName());
    
    public static final String PERSISTENCE_UNIT = "sat20";
    private JPAContainer<Users> persons;
    private String textFilter;
    private TextField searchField;

   
    public UserManagement(Context context, final Window mainWindow) {
        buildMainLayout();
        setCompositionRoot(mainLayout);
         HorizontalLayout toolbar = new HorizontalLayout();
         searchField = new TextField();
         searchField.setInputPrompt("Search by name");
         searchField.addListener(new TextChangeListener() {        
          
            private static final long serialVersionUID = 1L;

            public void textChange(TextChangeEvent event) {
                 textFilter = event.getText();
                 updateFilters();
             }
         });        
        
        mainLayout.addComponent(toolbar);
        toolbar.addComponent(searchField);
        toolbar.setWidth("100%");
        toolbar.setExpandRatio(searchField, 1);
        toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);
        
        persons = JPAContainerFactory.make(Users.class, PERSISTENCE_UNIT);
       
        persons.sort(new String[]{"nom"}, new boolean[]
{true});                                        
        
        table_1.setWidth("100%");
        
        table_1.setSelectable(true);
        table_1.setMultiSelect(false);.

        table_1.setContainerDataSource(persons);

        table_1.setColumnHeaders(new String[] { "MAIL", "USER_ID", "ADMIN", "ID", "NOM"});
               
        table_1.setPageLength(15);
       
      
    }
    

I’m pretty sure that it’s something related with the relationship Many to Many between Users and Context because if I remove it the problem is solved, any idea? please help me!

Thanks in advance!

Could be related with this thread

https://vaadin.com/forum#!/thread/2305723

Help me please, it’s very important!