Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister

前端 未结 6 1558
鱼传尺愫
鱼传尺愫 2020-12-28 12:33

I am actually new to hibernate and tried to set up 2 classes. Account and Person. Now all i try to do is create a one to one bidirectional dependency using annotations. Here

6条回答
  •  轮回少年
    2020-12-28 13:09

    If you look at the chain of exceptions, the problem is

    Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property salt in class backend.Account

    The problem is that the method Account.setSalt() works fine when you create an instance but not when you retrieve an instance from the database. This is because you don't want to create a new salt each time you load an Account.

    To fix this, create a method setSalt(long) with visibility private and Hibernate will be able to set the value (just a note, I think it works with Private, but you might need to make it package or protected).

提交回复
热议问题