Java entity - why do I need an empty constructor?

后端 未结 8 864
情歌与酒
情歌与酒 2020-12-08 07:23

This might sound stupid to you, but why do I need to define an empty constructor in my @Entitys?

Every tutorial I saw said : every entity needs an empty

8条回答
  •  生来不讨喜
    2020-12-08 07:47

    But java always give you a default invisible empty constructor (if you don't redefine one).

    This statement is true only when you don't provide any constructor in your class. If an argument constructor is provided in your class, then jvm will not add the no-argument constructor.

提交回复
热议问题