1

In the product class i have created parameterized construction while fetching data from data base i was getting error " No default constructor for entity ",

whenever we created parameterized construction in entity class. is default constructor mandatory to create?

1 Answers1

2

Hibernate require a no-arguments constructor to create a new instance of your entity using reflection. many framework work like this, check this good question about it Why does Hibernate require no argument constructor?

From Hibernate doc.:

All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with at least package visibility for runtime proxy generation in Hibernate.

pixelatedCat
  • 312
  • 5
  • 17