我需要提高Java JPA应用程序中Oracle lob检索的性能。
使用oracle.jdbc.defaultLobPrefetchSize参数对性能进行了很好的记录,但是该文档适用于诸如OracleConnection或OracleStatement之类的低级类。
如何在c3p0,JPA上下文中设置此lob设置?
在连接级别:
@Bean
public DataSource dataSource() throws SQLException, PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setJdbcUrl(this.dbProperties.getProperty("jdbc.url"));
dataSource.setUser(this.dbProperties.getProperty("jdbc.username"));
datasource.setPassword(this.dbProperties.getProperty("jdbc.password"));
dataSource.setDriverClass(this.dbProperties.getProperty("jdbc.driver"));
return dataSource;
}
@Bean
public LocalContainerEntityManagerFactoryBean myEmf() throws SQLException, PropertyVetoException {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource());
lef.setJpaVendorAdapter(jpaVendorAdapter());
lef.setJpaProperties(this.dbProperties);
return lef;
}
在查询级别:
@Transactional(readOnly=true)
public List<Data> findByXXX(String xxx) {
// Make/execute the typed query.
return this.entityManager.createQuery("SELECT d FROM Data d WHERE d.xxx = :xxx", Data.class)
.setParameter("xxx", xxx)
.getResultList();
}
谢谢。