Java JPA / Hibernate generates database schema twice
I recently tried switching my application from Hibernate SessionFactory to JPA EntityManager for Spring MVC project.
When I run my application with Jetty, the database schema is created twice. (I have hbm2ddl.auto installed for 'create').
In particular, I see this output twice:
INFO: Building JPA EntityManagerFactory for persistence unit 'default'
INFO: Initialized JPA EntityManagerFactory for persistence unit 'default'
The generated sql with hibernate also shows the same SQL queries being repeated twice.
Somehow the creator of the object is created twice.
I am using Hibernate version 5.2.9.Final, Spring version 4.3.5.RELEASE
Unfortunately, the project does not belong to me, so I donโt think I can release code samples. But I am wondering if anyone has run into this problem, and I would really appreciate it if someone could point me in a general direction where the problem might be.
I tried to switch between LocalEntityManagerFactoryBean
andLocalContainerEntityManagerFactoryBean
I also switched between using dataSource and persistence.xml
I also tried filtering <context:component-scan>
in dispatcher-servlet.xml
to exclude crawling for @Component
(to avoid the possibility of scanning multiple beans twice), but none of them will work!
Any help would be greatly appreciated.
source to share
No one has answered this question yet
Check out similar questions: