November 2018
Intermediate to advanced
388 pages
9h 5m
English
When we have multiple persistence units defined in the persistence.xml file, we need to inject the appropriate one to EntityManager using the @PersistenceContext annotation. We can point to a specific persistence unit using the PersistenceContext entity's unitName attribute.
Using @PersistenceContext on EntityManager, let's point to the integration unit:
@Statelessclass App { @Inject private lateinit var identityCreator: IdentityCreator @PersistenceContext(unitName = "integration") private lateinit var entityManager: EntityManager fun createIdentity(inputData: InputData): Person { val person = identityCreator.createPerson(inputData) entityManager.persist(person) return person } fun findAllPerson(): List<Identity> { return ...Read now
Unlock full access