Nick Div
Nick Div

Reputation: 5628

Hibernate not logging SQL queries fired even after enabling all the properties

I have logging enabling using the hibernate properties but still I am not able to see the SQL queries being fired

Here is my Spring configuration code:

        @Bean
        public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
            final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
            em.setDataSource(dataSource());
            em.setPackagesToScan("models");

            final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
            em.setJpaVendorAdapter(vendorAdapter);
            em.setJpaProperties(hibernateProperties());
            return em;
        }
        private Properties hibernateProperties() {
            return new Properties() {
                {
                    setProperty("hibernate.hbm2ddl.auto", hbm2ddlScheme);
                    setProperty("hibernate.dialect", dbDialect);
                    setProperty("hibernate.globally_quoted_identifiers", "true");
                    setProperty("hibernate.use_sql_comments", "true");
                    setProperty("hibernate.generate_statistics", "true");
                    setProperty("format_sql", formatSQL);
                    setProperty("show_sql", showSQL);
                    setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory");
                    setProperty("hibernate.cache.use_second_level_cache", "true");
                    setProperty("hibernate.cache.use_query_cache", "true");
                    setProperty("hibernate.cache.use_structured_entries", "true");
                    setProperty("net.sf.ehcache.configurationResourceName", "myehcache.xml");
                }
            };
        }

I do see the session stats though. I also want to see the queries that are being fired.

Upvotes: 1

Views: 249

Answers (1)

Alexey Semenyuk
Alexey Semenyuk

Reputation: 3303

Try to use hibernate.show_sql and hibernate.format_sql instead of show_sql and format_sql

Upvotes: 2

Related Questions