0

fellow coders!

I have following problem:

I'm fetching data from database with @Table entities and everything is perfect, but now I have to connect to multiple databases and I would like to preserve @Table annotations.

I've seen some solutions for multi-database access (like this) but I don't quite understand how to use @Table annotation with such solution. Is it somehow possible?

Community
  • 1
  • 1
Dmitry Sheyko
  • 27
  • 1
  • 6

1 Answers1

0
  1. Create separate packages for tables in each database.
  2. When defining the session factory, define the package of Tables related to the database.
  3. When defining DAO inject appropriate session factory to fetch the data.

Alternatively, define the annotated classes (the @Table classes are annotated classes) the in each session factory.

Jaiprakash
  • 599
  • 2
  • 7