<!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]<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"></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="dataSource" ref="dataSource" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="persistenceUnitManager" ref="persistenceUnitManager" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="jpaVendorAdapter"></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="showSql" value="false" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="generateDdl" value="false" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="database" value="ORACLE"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"></bean></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"></property></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="persistenceUnitName" value="dcPersistenceUnitTest" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"></bean></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]<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">   <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="jdbcUrl" value="${dc.url}" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="user" value="${dc.user}" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="password" value="${dc.password}" /></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><!--  C3P0 connection pool configuration --></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">   <property name="minPoolSize" value="5"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="maxPoolSize" value="20"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="checkoutTimeout" value="300"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="maxStatements" value="50"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><property name="maxIdleTime" value="300"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"></bean></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]<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/></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;">        <!-- LobHandler for Oracle JDBC drivers --></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">        <!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) --></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">        <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">                <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">        </bean></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;">        <!-- NativeJdbcExtractor for the C3P0 connection pool above --></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">        <!-- (just needed for oracleLobHandler) --></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">        <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;">                        lazy-init="true"/></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;"> </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;"> </p><p>[CODE]<bean id="entityManagerFactory" </p><p>class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"></p><p><property name="dataSource" ref="dataSource" /></p><p><span style="white-space: pre;"> </span><property name="persistenceUnitManager" ref="persistenceUnitManager" /></p><p><span style="white-space: pre;"> </span><property name="jpaVendorAdapter"></p><p><span style="white-space: pre;"> </span><bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></p><p><span style="white-space: pre;"> </span><property name="showSql" value="false" /></p><p><span style="white-space: pre;"> </span><property name="generateDdl" value="false" /></p><p><span style="white-space: pre;"> </span><property name="database" value="ORACLE"/><span style="white-space: pre;"> </span></p><p><span style="white-space: pre;"> </span><property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" /></p><p><span style="white-space: pre;"> </span></bean></p><p><span style="white-space: pre;"> </span></property></p><p><span style="white-space: pre;"> </span><property name="persistenceUnitName" value="dcPersistenceUnitTest" /></p><p></bean></p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[CODE]<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"></p><p><span style="white-space: pre;"> </span>    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /></p><p><span style="white-space: pre;"> </span><property name="jdbcUrl" value="${dc.url}" /></p><p><span style="white-space: pre;"> </span><property name="user" value="${dc.user}" /></p><p><span style="white-space: pre;"> </span><property name="password" value="${dc.password}" /></p><p><span style="white-space: pre;"> </span><!--  C3P0 connection pool configuration --></p><p><span style="white-space: pre;"> </span>    <property name="minPoolSize" value="5"/></p><p><span style="white-space: pre;"> </span><property name="maxPoolSize" value="20"/></p><p><span style="white-space: pre;"> </span><property name="checkoutTimeout" value="300"/></p><p><span style="white-space: pre;"> </span><property name="maxStatements" value="50"/></p><p><span style="white-space: pre;"> </span><property name="maxIdleTime" value="300"/> <span style="white-space: pre;"> </span></p><p><span style="white-space: pre;"> </span></bean></p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>However, it will NOT work for the statement below.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>[CODE]</p><p>OracleConnection oc = (OracleConnection) preparedStatement.getConnection();</p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p>[CODE]<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        <!-- LobHandler for Oracle JDBC drivers --></p><p>        <!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) --></p><p>        <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"></p><p>                <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/></p><p>        </bean></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>        <!-- NativeJdbcExtractor for the C3P0 connection pool above --></p><p>        <!-- (just needed for oracleLobHandler) --></p><p>        <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"</p><p>                        lazy-init="true"/></p><p>[/CODE]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Please advice.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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>