Hi Felipe,

you can inject EntityManager with @PersistenceContext
<http://docs.oracle.com/javaee/6/api/javax/persistence/PersistenceContext.html>
Configure your persistence like this persistence.xml
<https://github.com/apache/tomee/blob/master/examples/jpa-hibernate/src/main/resources/META-INF/persistence.xml>

Inject your EntityManager like this:
https://github.com/apache/tomee/blob/master/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java#L29-L30

See the sample (try running, test and explore it):
https://github.com/apache/tomee/tree/master/examples/jpa-hibernate


On Wed, Jul 15, 2015 at 2:36 PM, Felipe Jaekel <[email protected]> wrote:

> Hi,
>
> I need to enable Hibernate SQL output only when my webapp in running on my
> dev environment.
>
> On Tomcat since I could do something like this:
>
>
> Map<String, String> properties = new HashMap<String, String>();
> > if(ServerUtil.isLocal())
> > {
> > properties.put("hibernate.show_sql", "true");
> > properties.put("hibernate.format_sql", "true");
> > }
> > emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT,
> properties);
>
>
>
> Is there any way I can do something similar with the injected
> EntityManagerFactory on TomEE?
>
> Thanks
>



-- 
Best regard,
Daniel Cunha (soro)

Reply via email to