I have an abstract class and two subclasses that extend it. I have the following spring configuration file
<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" />
In my abstract class, I have the following methods
public void importDataToDB(){
}
@Transactional
public void executeInsertUpdateQuery(){
}
My java code
ImportConfigFiles importConfigFiles = (ImportConfigFiles)context.getBean("importConfigFile");
importConfigFiles.setFileLocation(destPath);
importConfigFiles.importDataToDB();
This does not work. executeInsertUpdateQuery () executes only one native SQL query. If I put @Transactional on imortDataToDB (), it works, but then it makes my transaction huge, because inside this method I look through all the lines in the file and insert the records in db.
source
share