私は抽象クラスとそれを拡張する2つのサブクラスを持っています。私のJavaコードは、これは動作しませんspring @ Transactional annotation
ImportConfigFiles importConfigFiles = (ImportConfigFiles)context.getBean("importConfigFile");
importConfigFiles.setFileLocation(destPath);
importConfigFiles.importDataToDB();
public void importDataToDB(){
//all the good stuff goes in here
}
@Transactional
public void executeInsertUpdateQuery(){
//all the good stuff goes in here
}
私は 春の設定ファイルに次のように持っている私の抽象クラスで
<bean id="importConfigFile" class="xxx.ImportConfigFiles" parent="parentImportFile"></bean>
<bean id="importFile" class="xxx.ImportUMTSKPIFiles" parent="parentImportFile"></bean>
<bean id="parentImportFile" name="parentImportFile" class="xxx.ImportUMTSFiles" abstract="true"></bean>
<tx:annotation-driven transaction-manager="transactionManager" />
私は、次の方法があります。 executeInsertUpdateQuery()は、ネイティブSQLクエリを1回だけ実行します。私が@TransactionalをimortDataToDB()に置くと、それは動作しますが、そのメソッドの中で私はファイル内のすべての行をループし、レコードをdbに挿入するので、トランザクションが膨大になります。
迅速な対応に感謝します。 – user373201