I am using Spring boot 1.5.18.RELEASE.
I have followed multiple data sources using following link:
but its working when I have data sources in same server.
Here is my case:
- datasource1 at one server: server1
- datasource2 at another server: server2
- Using native query I have to get the records by joining 2 data sources.
In above case, spring boot application is trying to check for table in server 1 only and as a result I am getting sql exception something like
SqlExceptionHelper - SQL Error: 1146, SQLState: 42S02
SqlExceptionHelper - Table 'datasource2.table2' doesn't exist
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table
'datasource2.table2' doesn't exist
How to resolve this issue ?
No, You can't do it. As each JPARepository belong to only on EntityManager and entity manager relate to a single database.