I have a custom Stored Procedure class which is extending jdbc.StoredProcedure but I have annotated this class with Spring @Component to bring this class bean into Spring context.
Why I am doing this?
- I wanted to add spring-retry on execute method which will work only on spring components
- I wanted to reused the compiled StoredProcedure instead of creating a new object and recompiling every time, in this way I can reuse the compiled StoredProcedure every time.
anything wrong with this kind of implementation? are there any issues we may see with this Spring component based StoredProcedure?
Ex:
@Component
public class ExampleStoredProcedure extends StoredProcedure {
@Autowired
private DataSource dataSource;
@Postconstruct
public void init() {
super.setDataSource(dataSource);
setSql("stored_procedure_name");
//TODO declare parameters
compile();
}
public void execute(){
//Todo set all parameters to ParameterSource
super.execute(parameterSource);
}
}