title: hibernate session.persist(object) create more rows in database
body: <p>Helo, </p>
  
  <p>I have method </p>
  
  <pre><code>public void createContest(Contest c) {      
      session.beginTransaction();
      session.persist(c);
      session.getTransaction().commit();
      logger.info("Contest saved successfully!");
  }
  </code></pre>
  
  <p>I call it in one place with one object but this method save the object Contest to the database 4x. What could be the problem?</p>
  
  <p>Here is Contest class:</p>
  
  <pre><code>@Entity
  @Table(name = "Contest")
  public class Contest implements java.io.Serializable {
  
  @Id
  @Column(name="CONTEST_ID", unique = true, nullable = false, precision = 5, scale = 0)
  @GeneratedValue
  private int id;
  
  @Column(name="NAME")
  private String name;
  
  @Column(name="DATE_OF_EVENT")
  private Date dateOfEvent;
  
  @Column(name="REG_OPEN")
  private Date regOpen;
  
  @Column(name="REG_CLOSE")
  private Date regClose;
  
  @Column(name="REG_RESTRICTION")
  private Boolean regRestriction;
  
  @Column(name="CAPACITY")
  private int capacity;
  
  @OneToMany(mappedBy="upperContest")
  private List&lt;Contest&gt; precontests;
  
  @ManyToOne(cascade={CascadeType.ALL})
  @JoinColumn(name="UPPER_CONTEST_ID")
  private Contest upperContest;
  
  @ManyToMany(cascade = {CascadeType.ALL})
  @JoinTable(name="MANAGING", 
              joinColumns={@JoinColumn(name="CONTEST_ID")}, 
              inverseJoinColumns={@JoinColumn(name="PERSON_ID")})
  private List&lt;Person&gt; managers;
  
  @OneToMany(mappedBy="contest")
  private List&lt;Team&gt; teams;
  
  public Contest(String name, Date dateOfEvent, Date regOpen,
          Date regClose, Boolean regRestriction) {
      this.name = name;
      this.dateOfEvent = dateOfEvent;
      this.regOpen = regOpen;
      this.regClose = regClose;
      this.regRestriction = regRestriction;
  
      this.precontests = new ArrayList&lt;Contest&gt;();
      this.managers = new ArrayList&lt;Person&gt;();
      this.teams = new ArrayList&lt;Team&gt;();
  }
  
  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;
  }
  
  public Date getDateOfEvent() {
      return dateOfEvent;
  }
  
  public void setDateOfEvent(Date dateOfEvent) {
      this.dateOfEvent = dateOfEvent;
  }
  
  public Date getRegOpen() {
      return regOpen;
  }
  public void setRegOpen(Date regOpen) {
      this.regOpen = regOpen;
  }   
  
  public Date getRegClose() {
      return regClose;
  }
  public void setRegClose(Date regClose) {
      this.regClose = regClose;
  }
  
  public Boolean getRegRestriction() {
      return regRestriction;
  }
  public void setRegRestriction(Boolean regRestriction) {
      this.regRestriction = regRestriction;
  }
  
  public int getCapacity() {
      return capacity;
  }
  
  public void setCapacity(int capacity) {
      this.capacity = capacity;
  }
  
  public Contest getUpperContest() {
      return upperContest;
  }
  
  public void setUpperContest(Contest c) {
      this.upperContest = c;
  }
  
  public List&lt;Contest&gt; getPrecontests() {
      return precontests;
  }
  
  public void addPrecontest(Contest e) {
      this.precontests.add(e);
  } 
  
  public void addManager(Person p){
      this.managers.add(p);
  }
  
  public void addTeam(Team t){
      this.teams.add(t);
  }
  
  public List&lt;Person&gt; getManagers(){
      return managers;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And now I have to add some text because of restrictions of stackoverflow. Such Cool. Very wow.</p>