MyBatis 3 で Spring 4 を使用しています。Oracle 11g でストアド プロシージャを呼び出して、ステージング テーブルから大量のデータを処理し、そのデータを他のいくつかのテーブルに挿入しています。ストアド プロシージャは、その内部で commit を呼び出します。ただし、何も永続化されておらず、例外や警告はなく、これ以外のログには何もありません。
11:59:48.297 DEBUG BaseJdbcLogger.debug - ==> Preparing: {call PKG_DIRECTORY.sp_process_staged_data}
11:59:48.318 DEBUG BaseJdbcLogger.debug - ==> Parameters:
これが私のマッパーファイルでの私の定義です
<insert id="processDirectory" statementType="CALLABLE">
{call PKG_DIRECTORY.sp_process_staged_data}
</insert>
ここにインターフェースがあります
public interface StagedDataMapper {
@Async
void processDirectory();
List<StageDirectory> getStagedDirectory(long institutionId);
List<StageAppointment> getStagedAppointment(long institutionId);
}
挿入、更新、選択を試みましたが、何も機能しません。
アップデート:
小さな間違いを見つけましたが、問題は修正されませんでした。
更新されたマッパー ファイル
<select id="processDirectory" statementType="CALLABLE">
{call PKG_DIRECTORY.sp_process_staged_data()}
</select>
データベースで call PKG_DIRECTORY.sp_process_staged_data() を直接実行でき、問題なく動作します。
更新 2:
これが私のMyBatis設定です:
@Configuration
public class PersistenceConfig {
@Autowired
Environment environment;
@Bean(name = "datasource")
public ComboPooledDataSource dataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass(environment.getRequiredProperty("c3p0.driver"));
dataSource.setJdbcUrl(environment.getRequiredProperty("c3p0.url"));
dataSource.setUser(environment.getRequiredProperty("c3p0.user"));
dataSource.setPassword(environment.getRequiredProperty("c3p0.password"));
dataSource.setInitialPoolSize(environment.getRequiredProperty("c3p0.initialPoolSize", Integer.class));
dataSource.setMaxPoolSize(environment.getRequiredProperty("c3p0.maxPoolSize", Integer.class));
dataSource.setMinPoolSize(environment.getRequiredProperty("c3p0.minPoolSize", Integer.class));
dataSource.setAcquireIncrement(environment.getRequiredProperty("c3p0.acquireIncrement", Integer.class));
dataSource.setMaxStatements(environment.getRequiredProperty("c3p0.maxStatements", Integer.class));
dataSource.setMaxIdleTime(environment.getRequiredProperty("c3p0.maxIdleTime", Integer.class));
return dataSource;
}
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage("org.something.core.domain");
return sessionFactory.getObject();
}
@Bean(name = "transactionManager")
public DataSourceTransactionManager dataSourceTransactionManager() throws PropertyVetoException{
return new DataSourceTransactionManager(dataSource());
}
}
そして私のマッパー
<insert id="processDirectory" statementType="CALLABLE">
{CALL PKG_DIRECTORY.SP_PROCESS_STAGED_DATA()}
</insert>
更新 3:
私は別の試みをしましたが、まだ運がありません。MyBatisを捨てることを考えると、これはそのような問題になりつつあります.
永続化設定を少し変更しました
public class PersistenceConfig {
@Autowired
Environment environment;
@Bean(name = "datasource")
public ComboPooledDataSource dataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource();
dataSource.setDriverClass(environment.getRequiredProperty("c3p0.driver"));
dataSource.setJdbcUrl(environment.getRequiredProperty("c3p0.url"));
dataSource.setUser(environment.getRequiredProperty("c3p0.user"));
dataSource.setPassword(environment.getRequiredProperty("c3p0.password"));
dataSource.setInitialPoolSize(environment.getRequiredProperty("c3p0.initialPoolSize", Integer.class));
dataSource.setMaxPoolSize(environment.getRequiredProperty("c3p0.maxPoolSize", Integer.class));
dataSource.setMinPoolSize(environment.getRequiredProperty("c3p0.minPoolSize", Integer.class));
dataSource.setAcquireIncrement(environment.getRequiredProperty("c3p0.acquireIncrement", Integer.class));
dataSource.setMaxStatements(environment.getRequiredProperty("c3p0.maxStatements", Integer.class));
dataSource.setMaxIdleTime(environment.getRequiredProperty("c3p0.maxIdleTime", Integer.class));
return dataSource;
}
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage("org.something.core.domain");
sessionFactory.setTransactionFactory(springManagedTransactionFactory());
return sessionFactory.getObject();
}
@Bean(name = "transactionManager")
public DataSourceTransactionManager dataSourceTransactionManager() throws PropertyVetoException{
return new DataSourceTransactionManager(dataSource());
}
@Bean
public SpringManagedTransactionFactory springManagedTransactionFactory() {
return new SpringManagedTransactionFactory();
}
}
mybatis バージョンを 3.3.0 から 3.2.8 に、mybatis-spring を 1.2.3 から 1.2.2 にロールダウンしました。
マッパーは次のようになります。
public interface StagedDataMapper {
void processDirectory();
List<StageDirectory> getStagedDirectory(long institutionId);
List<StageAppointment> getStagedAppointment(long institutionId);
}
コントローラー方式
@Transactional
@RequestMapping(value = "/directory/process", method = RequestMethod.POST)
public ResponseEntity processStagedDirectory() {
stagedDataMapper.processDirectory();
return new ResponseEntity(HttpStatus.ACCEPTED);
}