0

I am using hibernate in my java project but the hibernate i am using is a legacy one means the version which i am using is hibernate 3 more over i am using the hibernate of spring one that is spring dedicated hibernate ,

i was going through net and found regarding p6SPY . jar in which the queries generated by hibernate so instead of question marks the actual parmeter values are reflected which is very helpful from developer point of view , here is the link which i have gone through

http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-solution/

now i want to have same functionality for my application also but as i have told earlier that i am using hibernate which is spring oriented moreover our hibernate configuration is done in a single xml itself as shown below but please advise how i can configure such functionality of P6SPY in my application my hibernate xml is as shown below..

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-lazy-init="true" default-autowire="no">
    <bean id="dataSource" class="com.persist.NullConnectionCheckerOracleDataSource" destroy-method="close">
        <property name="user" value="GTO"/>
        <property name="password" value=""/>
        <property name="connectionCachingEnabled" value="true"/>
<!--        <property name="connectionCacheName" value="ia"/> -->
        <property name="connectionCacheProperties">
            <props>
                <prop key="MaxLimit">20</prop>               
                <prop key="MinLimit">0</prop>
                <prop key="InactivityTimeout">0 </prop>
                <prop key="ConnectionWaitTimeout">60</prop>
                <prop key="PropertyCheckInterval">60</prop>
                <prop key="ValidateConnection">true</prop>
            </props>
        </property>
        <property name="URL">
            <value>jdbc:oracle:thin:@ldap://ccs.fm.ldap://ccsgcm.gcm.com:4042ldap://hkg0799xus.fm.</value>
        </property>
        <property name="connectionProperties"> 
            <props> 
                <prop key="oracle.net.ldap_loadbalance">OFF</prop>
                <prop key="v$session.osuser">@db.osuser@</prop>
                <prop key="v$session.program">@db.program@</prop>
            </props> 
        </property> 
    </bean>

    <bean id="sessionFactoryTemplate" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configurationClass" value="org.hibernate.cfg.Configuration"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                <prop key="hibernate.jdbc.batch_size">30</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.use_outer_join">false</prop>
                <prop key="hibernate.max_fetch_depth">10</prop>
                <prop key="hibernate.default_batch_fetch_size">150</prop>
                <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
                <prop key="hibernate.connection.autoReconnect">true</prop>
                <prop key="hibernate.connection.release_mode">on_close</prop>
                <prop key="hibernate.cache.use_query_cache">false</prop>
                <prop key="hibernate.cache.use_second_level_cache">false</prop>
                <prop key="hibernate.cache.provider_configuration_file_resour ce_path">./config/ehcache-processor1/ehcache.xml</prop>
                <prop key="hibernate.cache.use_structured_entries ">true</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
            </props>
        </property>
    </bean>

    <bean id="txnManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    <bean id="hibernateSession" class="com.persist.HibernateSessionImpl">
        <constructor-arg><ref bean="sessionFactory"/></constructor-arg>
        <property name="txnManager" ref="txnManager"/>
    </bean>

    <bean id="hibernateAdmin" class="com.persist.HibernateAdministrationImpl">
        <constructor-arg><ref bean="sessionFactory"/></constructor-arg>
        <constructor-arg><ref bean="&amp;sessionFactory"/></constructor-arg>
    </bean>

    <bean id="systemProcessConfig" class="com.persist.SystemProcessConfiguration">
        <constructor-arg index="0" value="gp"/>
        <constructor-arg index="1" value="gp"/>
    </bean>
</beans>
user1620642
  • 79
  • 10

1 Answers1

0

First, you will want to use the latest version of P6Spy. There have been lots of improvements in the later versions. BTW - It is no longer hosted at SourceForge. You can grab the latest version from maven central.

For integration with Spring, please see the answer for this previously asked question.

Community
  • 1
  • 1
quintonm
  • 838
  • 1
  • 7
  • 20
  • Thanks a lot for the help i have downloaded the latest jar from the maven , but can you pls advise how can i modify my above xml to configure for P6Spy as the datasource tag in my above xml consisist of y database properties and the url you have shared consists of p6spy specific one so please advise what changes i need to do in my above xml – user1620642 Mar 22 '15 at 11:39
  • for the rest configuration i am using the following url http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-solution/ – user1620642 Mar 22 '15 at 11:40
  • Please see the example that I gave in this answer: http://stackoverflow.com/a/19994630/515348 It shows an existing data source definition in Spring along with the changes to add p6spy. BTW - The instructions you are following for configuring P6Spy are very out of date. The docs for configuring P6Spy 2.X can be found at http://p6spy.github.io/p6spy/2.0/configandusage.html. – quintonm Mar 26 '15 at 21:00