Many to many with Hibernate
Many to many with Hibernate In this article i want show how persist a many to many relationship, whith hibernate and jpa annotation. Hibernate always, for this relationship, generate 3 table. One table for entity and one join table. Cliente.java import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany; @Entity public class Cliente { private int id; private String name; private List<Societa> societa; @Id @GeneratedValue public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @ManyToMany public List<Societa> getSocieta() { return societa; } public void setSocieta(List<Societa> societa) { this.societa = societa; } } Societa.java import java.util.List; import javax.persistence.E...