In our application, we have two databases, one primary and the other read-replica, which is used just for reporting purpose.
Some part of our application reads-writes to primary DB whereas the reporting stuff in the application reads-only read-replica for performance reasons.
How should we design our DAO which expose CRUD operations for both purposes? Should we create two session factories and maintain it in DAO classes?
Please opine.
I have done it exactly like you said - same
.hbm.xml
configuration, same POJO Java class, different session factories. No problems so far. You just need to be aware which context you are working in.