[jboss-user] [Spring Integration] - Hibernate, nativeJdbcExtractor, spring, JPA
xiao fong
do-not-reply at jboss.com
Tue Sep 21 15:47:18 EDT 2010
xiao fong [http://community.jboss.org/people/runner1] created the discussion
"Hibernate, nativeJdbcExtractor, spring, JPA"
To view the discussion, visit: http://community.jboss.org/message/562962#562962
--------------------------------------------------------------
Hello,
I am using C3P0 connection pooling in my app. I also use "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean".
[CODE]<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="database" value="ORACLE"/>
<property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="dcPersistenceUnitTest" />
</bean>
[/CODE]
[CODE]<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="${dc.url}" />
<property name="user" value="${dc.user}" />
<property name="password" value="${dc.password}" />
<!-- C3P0 connection pool configuration -->
<property name="minPoolSize" value="5"/>
<property name="maxPoolSize" value="20"/>
<property name="checkoutTimeout" value="300"/>
<property name="maxStatements" value="50"/>
<property name="maxIdleTime" value="300"/>
</bean>
[/CODE]
However, it will NOT work for the statement below.
[CODE]
OracleConnection oc = (OracleConnection) preparedStatement.getConnection();
[/CODE]
So, I went through Spring documentation 3.x, it suggests that it can be done by using C3P0NativeJdbcExtractor.
I did some research on how to configure it in spring applicationContext.xml, however, I couldn't find anything using entityManagerFactory.
I am not quite sure where to use the following:
[CODE]<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>
<!-- LobHandler for Oracle JDBC drivers -->
<!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) -->
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
</bean>
<!-- NativeJdbcExtractor for the C3P0 connection pool above -->
<!-- (just needed for oracleLobHandler) -->
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
lazy-init="true"/>
[/CODE]
Please advice.
Thank you.
Hello,
I am using C3P0 connection pooling in my app. I also use "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean".
[CODE]<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="database" value="ORACLE"/>
<property name="databasePlatform" value="com.xxx.hibernate.OracleSpatialDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="dcPersistenceUnitTest" />
</bean>
[/CODE]
[CODE]<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="${dc.url}" />
<property name="user" value="${dc.user}" />
<property name="password" value="${dc.password}" />
<!-- C3P0 connection pool configuration -->
<property name="minPoolSize" value="5"/>
<property name="maxPoolSize" value="20"/>
<property name="checkoutTimeout" value="300"/>
<property name="maxStatements" value="50"/>
<property name="maxIdleTime" value="300"/>
</bean>
[/CODE]
However, it will NOT work for the statement below.
[CODE]
OracleConnection oc = (OracleConnection) preparedStatement.getConnection();
[/CODE]
So, I went through Spring documentation 3.x, it suggests that it can be done by using C3P0NativeJdbcExtractor.
I did some research on how to configure it in spring applicationContext.xml, however, I couldn't find anything using entityManagerFactory.
I am not quite sure where to use the following:
[CODE]<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>
<!-- LobHandler for Oracle JDBC drivers -->
<!-- (refers to the NativeJdbcExtractor above to get access to native OracleConnections) -->
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
</bean>
<!-- NativeJdbcExtractor for the C3P0 connection pool above -->
<!-- (just needed for oracleLobHandler) -->
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
lazy-init="true"/>
[/CODE]
Please advice.
Thank you.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/562962#562962]
Start a new discussion in Spring Integration at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100921/88e38f40/attachment-0001.html
More information about the jboss-user
mailing list