Failed to initialize JPA EntityManagerFactory: Unable to load class [pgsql_enum]

956 Views Asked by At

I have some entities where some fields are represented as enums, there is an error when starting spring boot. below is the code, tell me what to use?

    @Getter
    @Setter
    @ToString
    //@TypeDef(name = "Level", typeClass = ru.somepackege.Level.class)
    //@TypeDef(name = "Work", typeClass = ru.somepackege.Work.class)
    @Entity
    @Table(name = "employee")
    public class Employee {
    
      @Id
      @SequenceGenerator(
          name = "employee_id_seq",
          sequenceName = "employee_id_seq",
          allocationSize = 1)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "employee_id_seq")
      private Integer id;
    
      @Column(name = "work_experience")
      @Enumerated(EnumType.STRING)
      @Type(type = "pgsql_enum")
      private Work workExperience;
    
      @Column(name = "level_competencies")
      @Enumerated(EnumType.STRING)
      @Type(type = "pgsql_enum")
      private Level levelCompetencies;
    
      @Column(name = "is_active")
      private boolean isActive;
    
      @Override
      public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        KpiEmployeeProfile that = (KpiEmployeeProfile) o;
        return id != null && Objects.equals(id, that.id);
      }
    
      @Override
      public int hashCode() {
        return getClass().hashCode();
      }
    }
    main] [ERROR] j.LocalContainerEntityManagerFactoryBean: [] Failed to initialize JPA EntityManagerFactory: Unable to load class [pgsql_enum]
    main] [WARN ] ConfigServletWebServerApplicationContext: [] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [pgsql_enum]
    
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [pgsql_enum]

annotations over entity classes don't help @TypeDef

0

There are 0 best solutions below