简体   繁体   English

在 Spring 数据 Jpa 中,如何从两个不同的数据源运行 SQL 联合查询...?

[英]In Spring Data Jpa, how can I run an SQL union query from two different datasources...?

I need to perform a SQL join of two entities and with different data sources.我需要执行两个实体和不同数据源的 SQL 连接。 I have an entity A with datasource A and an entity B with datasource B, and I need to do something like this...我有一个带有数据源 A 的实体 A 和一个带有数据源 B 的实体 B,我需要做这样的事情......

"select new A(a,b) from A a, B b where a.id = b.id"

I'm using two databases and I have two datasources configuration, one for each我正在使用两个数据库,并且有两个数据源配置,每个配置一个

You can use middleware like mycat2 to do this.您可以使用像 mycat2 这样的中间件来执行此操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我无法配置两个数据源JPA Spring XML WildFly - I can not have two datasources configured JPA Spring XML WildFly Spring数据jpa在两个互斥的数据源上 - Spring data jpa on two mutually exclusive datasources 如何在 SpringBoot 中为不同的数据源配置 JPA 存储库? - How can I configure JPA repositories for different DataSources in SpringBoot? 如何在Spring Boot和Spring Data中使用两个Cassandra数据源? - How can I use two Cassandra datasources with Spring Boot and Spring Data? 如何通过基于两个属性检索特定 object 的方法名称来实现此 Spring 数据 JPA 查询? - How can I implement this Spring Data JPA query by method name that retrieve a specific object based on two properties? 如何在Spring Data JPA中运行辅助/增强查询以确定计算值? - How can I run a secondary / augmented query in Spring Data JPA to determine calculated value? 如何使用 Spring 引导在 JPA 存储库中编写 SQL 查询? - How can I write SQL query in JPA repository with Spring Boot? 如何从 Spring 数据 JPA 中的 id 解析不同的实体? - How can I resolve different entities from an id in Spring Data JPA? Spring Boot,带有多个数据源的Spring Data JPA - Spring Boot, Spring Data JPA with multiple DataSources 如何使用带有“从方法名创建查询”策略的Spring数据JPA来实现这两个简单查询? - How can I implement these 2 simple queries using Spring data JPA with the “query creation from method names” strategy?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM