0

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.

Reporter
  • 3,897
  • 5
  • 33
  • 47
  • 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 Answers1

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

Community
  • 1
  • 1
maksimov
  • 5,792
  • 1
  • 30
  • 38