title: Hibernate ignores constructor and setters
body: <p>I encountered an odd behavior when I tried to load some Objects from my Database using Hibernate 5.4.3.</p>
  
  <p>Let's say I have a Class A which contains an instance of Class B. Now I want to load Class A from my Database but for some instances of A B is null. To prevent that there are A's with B's that are null I used the code below:</p>
  
  <pre><code>@Entity
  public class A{
  
     @Id
     @GeneratedValue
     private Long id;    
  
     @OneToOne(cascade = CascadeType.ALL)
     private B b = new B();
  
     public setB(B b){
         if(b == null){
             this.b = new B();
         }else{
             this.b =b;
         }
     }
  
     public B getB(){
         return this.b;
     }
  }
  </code></pre>
  
  <p>Now when I use A's somehow I still get A's that have no instance of B. How is this possible?</p>