I'm having this error:
Exception in thread "main" org.hibernate.InstantiationException: No default constructor for entity: : principal.Cliente at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:120) at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:136) at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:737) at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:4755) at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1387) at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1375) at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.hydrateEntityState(EntityReferenceInitializerImpl.java:235) at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:107) at org.hibernate.loader.plan.exec.internal.EntityLoadQueryDetails$EntityLoaderRowReader.readRow(EntityLoadQueryDetails.java:255) at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:129) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:138) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:102) at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:186) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4120) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:502) at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:467) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:274) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1066) at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:176) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2540) at org.hibernate.internal.SessionImpl.get(SessionImpl.java:951) at principal.ClienteDAO.obtenContacto(ClienteDAO.java:83) at principal.Main.main(Main.java:43)
Have no idea why im getting that exception
EDIT1 here is principal.Cliente
public class Cliente { private String name; public Cliente(String name) { this.name= name; } }
EDIT 2 removed a bunch of useless code to make it look cleaner
hibernate. InstantiationException: No entity default constructor. The default constructor is a method of the constructor without any argument invoked when creating an instance of the class. Hibernate uses default construction to create bean object using reflections.
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.
Default Constructor - a constructor that is automatically created by the Java compiler if it is not explicitly defined.
Missing default constructor in principal.Cliente
I can say,
public class Cliente{ public Cliente(){} }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With