Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Im working on a legacy system that was implemented using Java 8, Primefaces, JSF, Spring and JPA.

The customer needs to migrate the database from MySQL 5.7 to MySQL 8. For this, I needed to update the version of the MySQL-Conector, Hibernate and JPA in the pom files.

But after that, I can't run the application, because I receive an error in one of the entities, that uses the @Inheritance(strategy = InheritanceType.JOINED) annotation:

Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister

I don't have any idea about the reason of this problem, I can't find any solutions.

The mapping was made as follows:

    @Table(name="pessoa")
    @Entity
    @Inheritance(strategy = InheritanceType.JOINED)
    @Getter @Setter
    public class Pessoa extends AbstractEntity<Long>  {
        private static final long serialVersionUID = -7428585903001862635L;
    
        public Pessoa(){
        }
        
        public Pessoa(Long id , String nome){
            this.setId(id);
            this.setNome(nome);
        }
    }

    @Table(name = "pessoafisica")
    @Entity
    @Getter
    @Setter
    public class PessoaFisica extends Pessoa implements Serializable {
    
        private static final long serialVersionUID = -3017813318797857897L;
    
        @Temporal(TemporalType.DATE)
        protected Date dataNascimento;
    
        @IgnoreTransform
        @Column(length = 11)
        protected String cpf;
    }

    @Table(name="pessoajuridica")
    @Entity
    @Getter @Setter
    public class PessoaJuridica extends Pessoa implements Serializable {
        private static final long serialVersionUID = -6454727392460542221L;
    
        @IgnoreTransform
        @Column(length = 14)
        private String cnpj;    
    
        @Column(length = 150, unique = true)
        private String razaoSocial;
        
        @Temporal(TemporalType.DATE)
        private Date dataAbertura;
    }

Stacktrace error:

DEBUG: org.hibernate.type.spi.TypeConfiguration$Scope - Scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration@74e50f42] to SessionFactoryImpl [org.hibernate.internal.SessionFactoryImpl@2bdedbb7]
ERROR: org.hibernate.AssertionFailure - HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Table georgina.pessoa not found
DEBUG: org.hibernate.type.spi.TypeConfiguration$Scope - Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@6d7c0795] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@2bdedbb7]
ERROR: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: georgina] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
WARN : org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [db.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: georgina] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [db.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: georgina] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1159)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: georgina] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)
    ... 21 more

I'm using: Spring 5.3.2 Java 1.8 Primefaces 5.3 Jsf 2.1 Hibernate validator 7.0.0-final hibernate-entitymanage 5.4.27-final hibernate-jpa-2.1-api 1.0.2-final spring-data-jpa 2.4.2-final


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
137 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...