<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Hibernate, nativeJdbcExtractor, spring, JPA
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/runner1">xiao fong</a> in <i>Spring Integration</i> - <a href="http://community.jboss.org/message/562962#562962">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Hello,</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I am using C3P0 connection pooling in my app. I also use "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean".</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[CODE]&lt;bean id="entityManagerFactory" </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="dataSource" ref="dataSource" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="persistenceUnitManager" ref="persistenceUnitManager" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="jpaVendorAdapter"&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="showSql" value="false" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="generateDdl" value="false" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="database" value="ORACLE"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/bean&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/property&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="persistenceUnitName" value="dcPersistenceUnitTest" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/bean&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[/CODE]</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[CODE]&lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160; &lt;property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="jdbcUrl" value="${dc.url}" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="user" value="${dc.user}" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="password" value="${dc.password}" /&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;!--&#160; C3P0 connection pool configuration --&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160; &lt;property name="minPoolSize" value="5"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="maxPoolSize" value="20"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="checkoutTimeout" value="300"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="maxStatements" value="50"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;property name="maxIdleTime" value="300"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/bean&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[/CODE]</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">However, it will NOT work for the statement below.</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[CODE]</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">OracleConnection oc = (OracleConnection) preparedStatement.getConnection();</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[/CODE]</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">So, I went through Spring documentation 3.x, it suggests that it can be done by using C3P0NativeJdbcExtractor. </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I did some research on how to configure it in spring applicationContext.xml, however, I couldn't find anything using entityManagerFactory. </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I am not quite sure where to use the following:</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[CODE]&lt;bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- LobHandler for Oracle JDBC drivers --&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) --&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/bean&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- NativeJdbcExtractor for the C3P0 connection pool above --&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- (just needed for oracleLobHandler) --&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lazy-init="true"/&gt;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[/CODE]</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Please advice.</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Thank you.</div><p>Hello,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am using C3P0 connection pooling in my app. I also use "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>[CODE]&lt;bean id="entityManagerFactory" </p><p>class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;</p><p>&lt;property name="dataSource" ref="dataSource" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="persistenceUnitManager" ref="persistenceUnitManager" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="jpaVendorAdapter"&gt;</p><p><span style="white-space: pre;"> </span>&lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="showSql" value="false" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="generateDdl" value="false" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="database" value="ORACLE"/&gt;<span style="white-space: pre;"> </span></p><p><span style="white-space: pre;"> </span>&lt;property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;/bean&gt;</p><p><span style="white-space: pre;"> </span>&lt;/property&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="persistenceUnitName" value="dcPersistenceUnitTest" /&gt;</p><p>&lt;/bean&gt;</p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>[CODE]&lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt;</p><p><span style="white-space: pre;"> </span>&#160;&#160;&#160; &lt;property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="jdbcUrl" value="${dc.url}" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="user" value="${dc.user}" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="password" value="${dc.password}" /&gt;</p><p><span style="white-space: pre;"> </span>&lt;!--&#160; C3P0 connection pool configuration --&gt;</p><p><span style="white-space: pre;"> </span>&#160;&#160;&#160; &lt;property name="minPoolSize" value="5"/&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="maxPoolSize" value="20"/&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="checkoutTimeout" value="300"/&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="maxStatements" value="50"/&gt;</p><p><span style="white-space: pre;"> </span>&lt;property name="maxIdleTime" value="300"/&gt; <span style="white-space: pre;"> </span></p><p><span style="white-space: pre;"> </span>&lt;/bean&gt;</p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>However, it will NOT work for the statement below.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>[CODE]</p><p>OracleConnection oc = (OracleConnection) preparedStatement.getConnection();</p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, I went through Spring documentation 3.x, it suggests that it can be done by using C3P0NativeJdbcExtractor. </p><p>I did some research on how to configure it in spring applicationContext.xml, however, I couldn't find anything using entityManagerFactory. </p><p>I am not quite sure where to use the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>[CODE]&lt;bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- LobHandler for Oracle JDBC drivers --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/bean&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- NativeJdbcExtractor for the C3P0 connection pool above --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- (just needed for oracleLobHandler) --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lazy-init="true"/&gt;</p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Please advice.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thank you.</p></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/562962#562962">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Spring Integration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>