Search code examples
javajakarta-eeseampersistence-unit

Seam - Multiple Persistence Units


Does Seam support multiple persistence units in its configuration? Also, when would you want to have or need multiple persistence units?

I am working on a generic component and right now, it only supports a single persistence unit which makes sense to me as I have never used more than 1 persistence unit per web application. So, I am having difficulty seeing where you would use more than a single persistence unit.

Thanks,

Walter


Solution

  • Does Seam support multiple persistence units in its configuration?

    I don't see why it wouldn't. Configure several persistence units and get them injected by name:

    @PersistenceContext(unitName="UNITNAME")
    private EntityManager em;
    

    Also, when would you want to have or need multiple persistence units?

    If you need to access multiples datasources.