[英]Using Spring StoredProcedure class to call a function
[英]Custom StoredProcedure class as a Spring component and extends jdbc StoredProcedure
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.
我为什么要这样做?
这种实现有什么问题吗? 这个基于 Spring 组件的 StoredProcedure 有什么问题吗?
前任:
@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);
}
}
尝试实现一个分层的应用程序架构,在其中使用 spring 重试您的服务,如下例所示:
https://dzone.com/articles/spring-retry-way-to-handle-failures
这些服务方法可以定义事务边界并调用您的数据持久层方法,这些方法可以基于 spring 数据的标准化方法来调用存储过程和管理数据库连接等。
有关 Spring 和架构的更多信息,请参阅此简介:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.