【发布时间】:2017-04-28 21:34:10
【问题描述】:
我目前正在开发一个基于 Spring Boot 框架的应用程序,该框架使用 JPA 入站通道适配器从关系数据库中检索数据。我有一个名为 GetEmployee 的存储过程,它需要接受一个根据运行应用程序的服务器实例而变化的值。
我查看了适配器上的 Spring documentation,它提到了一个名为 int-jpa:parameter 的标签,但这似乎只在 named-query 属性为使用而不是 native-query 属性。
int-jpa:inbound-channel-adapter标签上还有一个parameter-source属性,但是我没有找到任何关于如何使用它的好文档。
有没有办法将参数从 Spring bean 传递到本机查询?还是使用命名查询属性的更好方法?
配置 XML:
<int-jpa:inbound-channel-adapter
id="employeeAdapter"
channel="employeeChannel"
entity-manager-factory="entityManagerFactory"
entity-class="com.example.entities.Employee"
native-query="EXEC emp.dbo.GetEmployee"
expect-single-result="false"
delete-after-poll="false">
<int:poller fixed-rate="10000">
<int:transactional propagation="REQUIRED" isolation="DEFAULT"
transaction-manager="transactionManager" />
</int:poller>
</int-jpa:inbound-channel-adapter>
【问题讨论】:
标签: java spring spring-integration spring-data-jpa