How to use Hibernate profiler in Spring EntityManager setup

109 views
Skip to first unread message

Kusi

unread,
Mar 20, 2011, 4:02:31 PM3/20/11
to Hibernate Profiler
In the setup instructions is only described how to use Hibernate
profiler with Springs SessionFactoryBean. How must it be used with
EntityManagerSetup instead. Here my example of Hibernate setup in
Spring context:




<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.jdbcurl}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>


<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="mydb" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="$
{db.dialect}" />
<property name="showSql" value="${db.showSql}" />
<!-- property name="generateDdl" value="true" /-->
</bean>
</property>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>

Eric Hauser

unread,
Mar 20, 2011, 6:08:28 PM3/20/11
to hibernate...@googlegroups.com
The easiest way would to be to call HibernateProfiler.initialize() via code.  If you don't have an entry point in your application to do this, you could create a factory bean that invokes the method or I believe there is a fancy new way to do this in SpringEL -- but I haven't used it.
Reply all
Reply to author
Forward
0 new messages