These are chat archives for hibernate/hibernate-orm

14th
Feb 2018
Begović
@istiti
Feb 14 15:04
Hello im using springboot & hibernate, how can I put() in my Properties properties = new Properties(); property to enable hibernate statistics I tried hibernate.generate_statistics and org.hibernate.stat to DEBUG but nothing in my console ?
mlk5060
@mlk5060
Feb 14 15:09
@istiti You need to have your class that constructs the Properties object implement EnvironmentPostProcessor. The postProcessEnvrionment method implemented has two method parameters: a ConfigurableEnvironment and SpringApplication. If you invoke ConfigurableEnvironment.getPropertySources() you will get a MutablePropertySources object and you should then replace your Properties object with a HashMap<String, Object> and add your property keys and values into it. After constructing the HashMap of your Hibernate properties, invoke propertySources.addFirst(new MapPropertySource("hibernateProperties", yourHashMap));. Finally, add a spring.factories file to your Spring Boot application's src/main/resources/META-INF directory and add the following line: org.springframework.boot.env.EnvironmentPostProcessor=com.path.to.your.class.containing.the.hashmap.
@istiti the problem you're having is that the Spring container is not being refreshed after you set your properties, so they are ignored. The advice I gat you there is from Andy Wilkinson, who works on the Spring Boot development team. Doing what I've told you will ensure that the properties are picked up and included in the Spring container context before the properties defined are actioned.
Begović
@istiti
Feb 14 15:14
@mlk5060 weird i juste add it inside ApplicationConfiguration.java and seems working without doing waht you say
image.png
this is caled inside my sessionFactory()
mlk5060
@mlk5060
Feb 14 15:15
@istiti Ah, OK. What I've told you is the safest option but, if you want to do it that way and it works, be it on your head!
Begović
@istiti
Feb 14 15:16
@mlk5060 of course this is useful to know
mlk5060
@mlk5060
Feb 14 15:17
@istiti :+1: How is your ApplicationConfiguration annotated, just with @Configuration?
Begović
@istiti
Feb 14 15:17
@mlk5060 just curious, you use spring boot hibernate ? and waht bdd ?
mlk5060
@mlk5060
Feb 14 15:18
@istiti Yes, our databases use a combination of Liquibase, JPA, Hibernate, and Envers. I'm not sure what you mean by BDD? I only know that as "Behaviour Driven Design"
Begović
@istiti
Feb 14 15:18
image.png
@mlk5060 database ?
mlk5060
@mlk5060
Feb 14 15:19
*database management
Begović
@istiti
Feb 14 15:19
im using mssql
and have randomly reponse time
mlk5060
@mlk5060
Feb 14 15:19
Ah. Either H2 or Postgresql
Begović
@istiti
Feb 14 15:19
often it's fast but for same request it can take a while
and it seems msssql is problem and i really don't understand this is annoying
mlk5060
@mlk5060
Feb 14 15:20
I've never used that database provider before
Steve Ebersole
@sebersole
Feb 14 17:17
@rahulg963 true, that circumvents the possibility of batching
one of the many reasons we suggest to bypass usng IDENTITY
@istiti which version of mssql? older versions and even newer versions depending on the isolation you use) can really struggle with locks