Hibernate buildSessionFactory() Exception

前端 未结 4 1896
一向
一向 2021-01-02 14:21

I have a serious problem with hibernate. I followed various books und online tutorials, but I ever get the same Exception \"ExceptionInInitializerError\" obviously thrown by

4条回答
  •  天涯浪人
    2021-01-02 14:38

    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.

提交回复
热议问题