Conditional properties to EntityManagerFactory

2015-07-15 Thread Felipe Jaekel
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 properties = new HashMap(); > if(ServerUtil.isLocal()) > { > properties.put("hibernate.show_sql", "true"); > properties.put("hibernate.format_sql",

Re: Conditional properties to EntityManagerFactory

2015-07-15 Thread Daniel Cunha
Hi Felipe, you can inject EntityManager with @PersistenceContext Configure your persistence like this persistence.xml

Re: Conditional properties to EntityManagerFactory

2015-07-17 Thread Felipe Jaekel
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

Re: Conditional properties to EntityManagerFactory

2015-07-17 Thread Daniel Cunha
If I get it.. You need to have something like DeltaSpike ProjectStage[1] where you have a configuration for Development and another configuration for Production. So, maybe you can create a different Produce for each stage. Then with Alternative and Exclude annotations you can configure it. I'm n

Re: Conditional properties to EntityManagerFactory

2015-07-17 Thread Romain Manni-Bucau
Well I'd just put the properties I want in conf/system.properties. Side note: if you want to do it by persistence unit you can as well prefixing it by PERSISTENCEUNIT and the unit name as explained here http://tomee.apache.org/properties-listing.html Romain Manni-Bucau @rmannibucau

Re: Conditional properties to EntityManagerFactory

2015-07-17 Thread Yann Blazart
Hello ! I made a such thing for one client. In facts and brievly, I made a persistence provider that was able to load propperties and create a delegated real persistence provider (hibernate for example). In my persistence.xml I refered to my own persistence provider. In this way I'm able to dy

Re: Conditional properties to EntityManagerFactory

2015-07-17 Thread Yann Blazart
And yes that's working too, but only for TomEE ;) I'm using this in my "units" tests with app composer (thanks Romain !) Well I'd just put the properties I want in conf/system.properties. > Side note: if you want to do it by persistence unit you can as well > prefixing it by PERSISTENCEUNIT and

Re: Conditional properties to EntityManagerFactory

2015-07-17 Thread Felipe Jaekel
Adding *hibernate.show_sql=true* and *hibernate.format_sql=true* to *system.properties* did the trick Thank you all 2015-07-17 14:05 GMT-03:00 Yann Blazart : > And yes that's working too, but only for TomEE ;) > > I'm using this in my "units" tests with app composer (thanks Romain !) > > Well I'