Search code examples
springhibernatejakarta-eespring-mvcspring-roo

Multiple persistence files in spring


I'm trying to create multiple modules with multiple persistence xml files. Idea is to keep entity classes inside same module it belongs to.

Module 'A' configured with JPA with persistence.xml and working fine. Module 'B' has dependency with Module 'A' and has its own persistence.xml.

When I try to use I get

 IllegalStateException:Conflicting persistence unit definitions for name in

I'm building this test app with spring roo. Please shed a light on this. cheers


Solution

  • Review the persistance unit names in each persistence.xml

    Something like persistanceUnit for the Module A (that works fine) and persistanceUnitB for Module B.

    Besides, you'll have to asign the appropriate persistance unit to each Entity. You can use the corresponding attribute in the Roo annotation