deltaspike-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <>
Subject [jira] [Commented] (DELTASPIKE-315) Provide a producer for EntityManagerFactories
Date Fri, 22 Feb 2013 07:10:13 GMT


Mark Struberg commented on DELTASPIKE-315:

~lightguard course we do. That is one of the most important features. That we we can easily
switch between different configurations depending on the database vendor, the project stage,
etc. It's e.g. possible to pickup non-jta credentials for test but take a DataSource from
JNDI for production.

I will create a patch and ship it to my github repo this afternoon.

I also would like to use meta-Qualfiers, e.g. 

public @interface UserDb {}

That should work in theory, but I need to test with all containers.

> Provide a producer for EntityManagerFactories
> ---------------------------------------------
>                 Key: DELTASPIKE-315
>                 URL:
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: JPA-Module
>    Affects Versions: 0.3-incubating
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>             Fix For: 0.4-incubating
> I found myself using the following pattern quite often in projects in the last time.
I have a @Qualifier UnitName(value) and a producer for a @Dependent EntityManagerFactory for
it. The configuration is mostly provided via the persistenceProperties Map in EntityManagerFactory#createEntityManagerFactory(unitname,
> We can further tweak the config lookup path and define a route which makes the most sense.
> This can be used to create the EntityManager producer very easily.
> @ApplicationScoped
> public class MyEntityManagerProducer {
>   private @Inject @UnitName("orderUnit") EntityManagerFactory emf;
>   @Produces @RequestScoped
>   public EntityManager createEm() {
>     return emf.createEntityManager();
>   }
>   .. + disposer 
> }
> Please note that the EMF producer doens't clash with anything else as it only produces
EMFs with the Qualifier @UnitName!

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message