Hi, Persistence is working fine...
My demand is to enable hibernate's generated sql output only when the webapp is running locally. persistence.xml is not an option because I cannot afford to forget this setting enabled and send the webapp to production with it, since the server will run out of disk space in a few days because of the very fast growth of the log files. When I migrated my webapp to TomEE I started to use the injected EntityManagerFactory that was already created, so I can't pass a map of properties to it like I used to do in Tomcat. I'd like to know if is it possible to intercept TomEE's EntityManagerFactory creation. Thanks 2015-07-15 14:45 GMT-03:00 Daniel Cunha <daniels...@gmail.com>: > 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 <fkjae...@gmail.com> 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) >