0

I want to know query execution time so i follow this answer

   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitName" value="persistenceYous" />
      <property name="dataSource" ref="dataSource" />
      <property name="packagesToScan" value="persistence" />
      <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />

   </bean>

 <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="showSql" value="true" />
    <property name="generate_statistics" value="true" />
</bean>

but i got this error

Caused by: org.springframework.beans.NotWritablePropertyException: 
Invalid property 'generate_statistics' of bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: 
Bean property 'generate_statistics' is not writable or has an invalid setter method. 
Does the parameter type of the setter match the return type of the getter?
Community
  • 1
  • 1
Hayi
  • 6,972
  • 26
  • 80
  • 139

1 Answers1

2

Have you tried to write the property into the persistence.xml instead? (This is only a guess)

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"      
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
                       http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit ...>
    ...    
    <properties>
        ...
        <property name="hibernate.generate_statistics" value="true" />
    </properties>
    ...
</persistence-unit>

without persistence.xml:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
   ...
   <property name="jpaVendorAdapter" .../>
   <property name="jpaPropertyMap">
      <map>
        <entry key="hibernate.generate_statistics" value="true"/>
      </map>
   </property>
</bean>
Ralph
  • 118,862
  • 56
  • 287
  • 383