JPA 2.0: Adding entity classes to PersistenceUnit *from different jar* automatically

前端 未结 8 559
余生分开走
余生分开走 2020-11-29 02:23

I have a maven-built CDI-based Java SE app, which has a core module, and other modules.
Core has the persistence.xml and some entities. Modules hav

8条回答
  •  [愿得一人]
    2020-11-29 02:45

    I have a similar problem and solved it with Hibernate's Integrator SPI:

    @Override
    public void integrate(Configuration configuration,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
    
        configuration.addAnnotatedClass(MyEntity.class);
        configuration.buildMappings();
    }
    

    The Integrator is provided as Java service.

提交回复
热议问题