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
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?
- Create separate packages for tables in each database.
- When defining the session factory, define the package of Tables related to the database.
- 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.