wonder . thanks . --
*Daniel Dias dos Santos* Java Developer SouJava & JCP Member GitHub: https://github.com/Daniel-Dos Linkedin: http://br.linkedin.com/in/danieldiassantos Twitter: http://twitter.com/danieldiasjava Em qui, 30 de ago de 2018 às 15:35, Mark Struberg <[email protected]> escreveu: > > I understand that the same is only used for a Java EE Full. > > > @PersistenceContext works whenever you have the container manage the > Transaction. > > You have it in FullProfile, WebProfile and also if you happen to have a > standalone or embedded EJB container like OpenEJB. > > If you just have Tomcat + a CDI integration then you must use > Persistence.createEntityManagerFactory otoh. > > LieGrue, > strub > > > Am 30.08.2018 um 20:07 schrieb Daniel Dias Dos Santos < > [email protected]>: > > > > Hello Mark, > > > > I understand that the same is only used for a Java EE Full. > > > > So that part of the doc is wrong? > > > > > https://github.com/apache/deltaspike/blame/master/documentation/src/main/asciidoc/jpa.adoc#L72-L96 > > > > Many thanks for the explanations and support. > > -- > > > > *Daniel Dias dos Santos* > > Java Developer > > SouJava & JCP Member > > GitHub: https://github.com/Daniel-Dos > > Linkedin: http://br.linkedin.com/in/danieldiassantos > > Twitter: http://twitter.com/danieldiasjava > > > > > > Em qui, 30 de ago de 2018 às 05:37, Mark Struberg > <[email protected]> > > escreveu: > > > >> Hi Daniel! > >> > >> The @PersistenceContext is only used in case you have a real JavaEE > >> container like TomEE, WildFly, etc. > >> > >> In any other case the manual creation of the EntityManagerFactory is > fine. > >> Although I'd only create the EMF once, e.g. in a @PostConstruct method > in > >> your @ApplicationScoped bean. > >> Or you use the DeltaSpike @UnitName. > >> I just figured that our Docs (and JavaDocs) do not yet contain my latest > >> changes. > >> > >> By default using @UnitName("MYDB") the > >> PersistenceConfigurationProviderImpl will load a file > >> persistence-MYDB.properties. > >> > >> In addition you can also use deltaspike-config to override/extend those > >> persistence settings: > >> > >> > https://github.com/apache/deltaspike/blob/master/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/PersistenceConfigurationProviderImpl.java#L46 > >> > >> Just use a property > >> deltaspike.persistence.config.MYDB.some.jpa.property. > >> This will lead to having 'some.jpa.property' added to the > >> EntityManagerFactory property map. > >> > >> LieGrue, > >> strub > >> > >> > >>> Am 30.08.2018 um 06:55 schrieb Daniel Dias Dos Santos < > >> [email protected]>: > >>> > >>> Hello everyone, > >>> > >>> I have an example of a simple app using the Data module of the > >> deltaSpike and following what it says in the link: > >>> > >>> http://deltaspike.apache.org/documentation/jpa.html > >>> > >>> but instead of using JPA I am using Data in TomCat . > >>> > >>> my class manufactures this as in documentation: > >>> > >>> public class JUGFactory { > >>> > >>> @PersistenceContext > >>> private EntityManager entityManager; > >>> > >>> @Produces > >>> @RequestScoped > >>> public EntityManager createEntityManager() > >>> { > >>> return this.entityManager; > >>> } > >>> > >>> public void closeEntityManager(@Disposes EntityManager > entityManager) > >>> { > >>> if (entityManager.isOpen()) > >>> { > >>> entityManager.close(); > >>> } > >>> } > >>> } > >>> > >>> > >>> but in this way when executing the action, he throws me an exception > >> (attached) > >>> > >>> now it is left as follows: > >>> > >>> @ApplicationScoped > >>> public class JUGFactory { > >>> > >>> @Produces > >>> @RequestScoped > >>> public EntityManager criarEntityManager() { > >>> EntityManagerFactory emf = > >> Persistence.createEntityManagerFactory("soujava-rio"); > >>> return emf.createEntityManager(); > >>> } > >>> > >>> public void closeEntityManager(@Disposes EntityManager manager) { > >>> manager.close(); > >>> } > >>> } > >>> > >>> it works normal . > >>> > >>> thanks. > >>> > >>> -- > >>> Daniel Dias dos Santos > >>> Java Developer > >>> SouJava & JCP Member > >>> GitHub: https://github.com/Daniel-Dos > >>> Linkedin: http://br.linkedin.com/in/danieldiassantos > >>> Twitter: http://twitter.com/danieldiasjava > >>> <Exception.txt> > >> > >> > >
