In JPA entity class , What is the use of having constructor either default or argument constructor. I have read many articles regarding that. But none of that give an detailed explanation about that.
Asked
Active
Viewed 1,955 times
0
-
I guess you came across this question? http://stackoverflow.com/questions/1027385/empty-constructors-and-setters-on-jpa-entites – dbalakirev Jun 13 '12 at 08:27
1 Answers
2
So that entity manager could create an entity and then initialise the fields through the setters.
For example here:
MeEntity entity = em.find(MyEntity.class, id);
See here as well: Java default constructor
-
Then what is the use of creating the default constructor automatically by the jvm – user1227591 Jun 13 '12 at 08:26
-
Default constructor is only assumed/generated when there's no other constructor. – maksimov Jun 13 '12 at 08:29