[ 
https://issues.apache.org/jira/browse/DELTASPIKE-315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13581474#comment-13581474
 ] 

Mark Struberg commented on DELTASPIKE-315:
------------------------------------------

Romain, we should gather the info about EntityManagers on the DeltaSpike CMS 
page. This clearly only addresses resource-local aka 'native' EntityManagers. 
Some people prefer this over container managed EMs because there is sadly no 
single container working the same way. All of them use a different JNDI 
location, etc. 

I'm -1 to use the javax.* namespace in a way which is not intended by the specs 
as well. That might confuse users.

The benefit of my approach is that the producer does nothing until someone uses 
the @UnitName qualifier. 

Regarding 'making it easier'. Imo that's all a question of how we handle the 
configuration of the Map we pass to the EntityManagerFactory.

We at least need the following coordinates/overloadability:

* default values (useful for some default configuration of the JPA provider)
* ProjectStage (useful for having different settings depending on Development 
vs Production, etc)
* Database Vendor (useful to switch between different database vendors via 
config or maven property)


                
> Provide a producer for EntityManagerFactories
> ---------------------------------------------
>
>                 Key: DELTASPIKE-315
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-315
>             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, 
> persistenceProperties);
> 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: http://www.atlassian.com/software/jira

Reply via email to