2016-09-12 38 views
1

我想从应用程序动态更改被调用的存储过程的名称,而无需使用SimpleJDBC部署我的应用程序。如何在使用Spring时动态更改存储过程的名称SimpleJdbcCall

我正在使用连贯缓存来缓存在控制表中维护的存储过程的活动版本。在不改变存储过程的输入/输出的情况下改变功能的情况下,我部署新版本的存储过程并更新控制表中的新名称。在高速缓存的TTL(生存时间)过期并刷新高速缓存之后,新名称可供应用程序使用。

但是我的观察是,即使刷新缓存执行语句调用了部署过程中可用的存储过程的旧版本,我怎样才能改变这种

Map response = simpleJdbcCall.execute(new MapSqlParameterSource(map)); 

任何帮助,这是极大的赞赏。

谢谢

回答

0

看起来像你的设计有问题。

SimpleJdbcCall是一次性编译对象:

/** 
* Compile this JdbcCall using provided parameters and meta data plus other settings. 
* <p>This finalizes the configuration for this object and subsequent attempts to compile are 
* ignored. This will be implicitly called the first time an un-compiled call is executed. 
* @throws org.springframework.dao.InvalidDataAccessApiUsageException if the object hasn't 
* been correctly initialized, for example if no DataSource has been provided 
*/ 
public synchronized final void compile() throws InvalidDataAccessApiUsageException { 

所以,你不能在运行时改变它的内部状态。

但我可以建议你像每个新程序名称的新缓存实例的解决方案。为此,您可以编写一些@Cached服务,它将返回一个SimpleJdbcCall实例。因此,如果您过期缓存,则会为您创建一个新实例,并且您有责任将实际过程名称填充到该新对象。

P.S.是的,Spring Integration没什么,请小心选择问题的标签。

相关问题