title: Java entity - why do I need an empty constructor?
body: <p>This might sound stupid to you,
  but why do I need to define an empty constructor in my <code>@Entity</code>s?</p>
  <p>Every tutorial I saw said : every entity needs an empty constructor.</p>
  <p>But Java always give you a default invisible empty constructor (if you don't redefine one).</p>
  <p>Let me clarify..
  What I understood by &quot;need&quot; was <em>write</em>.</p>
  <p>Meaning: always write an empty constructor in your entity.</p>
  <p>example:</p>
  <pre><code>@Entity
  public class MyEntity implements Serializable {
  
     @Id
     private String str;
  
     public MyEntity(){}
  
     //here getter and setter
  }
  </code></pre>
  <p>But Java always gives you this empty constructor when you don't redefine it (write an other one with parameters).</p>
  <p>In this case writing this empty constructor seems useless.</p>