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