title: hibernate initiate correctly OneToOne object
body: <p>I have the next situation. I have POJO class:</p>
  
  <pre><code>    @Entity
      @Table(name="project")
      public class Project {
  
          public Donation donation;
  
          public Project() {}
          public Project(int param1, int param2 ...) {
              ...//other field initialisied
              donation = new Donation(param1, param2);
          }
  
          //methods
  
          @OneToOne
          @JoinColumn(name = "donation_project_id")
          public Donation getDonation() {
              return donation;
          }
      }
  
          public void setDonation(Donation donation) {
              this.donation = donation;
          }
      }
  </code></pre>
  
  <p><strong>Donation</strong> class:</p>
  
  <pre><code>@Entity
  @Table(name="donation")
  public class Donation {
  
          public Donation() {}
  
          public DonationLogic(int param1, int param2) {
              //initialisation
          }
          //other methods
  }
  </code></pre>
  
  <p><em>Project</em> table/class relays some parameters to another table/class <em>Donation</em>. Two classes are Entities. And I use Spring+Hibernate. My question is if I correctly initiate class <em>Donation</em> which is created in constructor of <em>Project</em> class? I think using <strong>new</strong> operator inside Spring smells bad. Maybe there is another way to do this task? - create class/table that is filled from another table/class. Maybe separate parameters for two classes and not use one constructor to initiate to classes? But use setters of Donation class? However if I have many parameters, many setters I will need to use((( Hmm((</p>