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

前端 未结 6 1535
鱼传尺愫
鱼传尺愫 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 12:45

    You are missing setter for salt property as indicated by the exception

    Please add the setter as

     public void setSalt(long salt) {
          this.salt=salt;
     }
    
    0 讨论(0)
  • 2020-12-28 12:49

    I encountered this error when upgrading from jdk10 to jdk11. Adding the following dependency fixed the problem:

    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.25.0-GA</version>
    </dependency>
    
    0 讨论(0)
  • 2020-12-28 12:56

    I resolved this issue by excluding byte-buddy dependency from springfox

    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.7.0</version>
      <exclusions>
      <exclusion>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy</artifactId>
      </exclusion>
      </exclusions>
    </dependency>
    
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>2.7.0</version>
      <exclusions>
      <exclusion>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy</artifactId>
      </exclusion>
    </exclusions>
    </dependency>
    
    0 讨论(0)
  • 2020-12-28 12:58

    In my case the problem was because of conflicting Jars.

    Here is the full list of jars which is working absolutely fine for me.

    antlr-2.7.7.jar
    byte-buddy-1.8.12.jar
    c3p0-0.9.5.2.jar
    classmate-1.3.4.jar
    dom4j-1.6.1.jar
    geolatte-geom-1.3.0.jar
    hibernate-c3p0-5.3.1.Final.jar
    hibernate-commons-annotations-5.0.3.Final.jar
    hibernate-core-5.3.1.Final.jar
    hibernate-envers-5.3.1.Final.jar
    hibernate-jpamodelgen-5.3.1.Final.jar
    hibernate-osgi-5.3.1.Final.jar
    hibernate-proxool-5.3.1.Final.jar
    hibernate-spatial-5.3.1.Final.jar
    jandex-2.0.3.Final.jar
    javassist-3.22.0-GA.jar
    javax.interceptor-api-1.2.jar
    javax.persistence-api-2.2.jar
    jboss-logging-3.3.2.Final.jar
    jboss-transaction-api_1.2_spec-1.1.1.Final.jar
    jts-core-1.14.0.jar
    mchange-commons-java-0.2.11.jar
    mysql-connector-java-5.1.21.jar
    org.osgi.compendium-4.3.1.jar
    org.osgi.core-4.3.1.jar
    postgresql-42.2.2.jar
    proxool-0.8.3.jar
    slf4j-api-1.6.1.jar
    
    0 讨论(0)
  • 2020-12-28 12:59

    in my case, the problem got solved only by implementing serializable as below:

    @Entity @Table(name = "User" , uniqueConstraints = { @UniqueConstraint(columnNames = {"nam"}) }) public class User extends GenericT implements Serializable

    0 讨论(0)
  • 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).

    0 讨论(0)
提交回复
热议问题