Hibernate buildSessionFactory() Exception

▼魔方 西西 提交于 2019-11-30 20:09:18

aused by: java.lang.NullPointerException at de.marcelstuht.nerven2.shared.model.Account.(Account.java:52) ... 49 more

Remove anything from your constructor in Account. You have a circular dependency. And Hibernate uses the public no args consructor for its beans

  1. HibernateUtil loads
  2. That forces the static to run buildSessionFactory
  3. Hibernate instantiates Account via no args
  4. That in turn calls HibernateUtil.....

Trust me: public no arg constructor with NO code, except POJO setters. Nothing else.

Please check the javassist.X.X.jar is in your classpath.

Ibrahim Mustafa

I ran into this problem once before. I eventually discovered that adding a non-annotated method to the entity where annotations are decorating the getter methods, gets you in this situation. If you make the annotations around the fields rather than the getter methods, then you can have extra unmapped methods.

I too experienced the "Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister" and adding javassist.X.X.jar to the classpath took care of it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!