Hibernate using multiple databases

后端 未结 9 2110
死守一世寂寞
死守一世寂寞 2020-12-05 05:25

Someone know how to add a another datasource in hibernate configuration and how to configure Spring to that datasource its autoinject in my respective DAO?

This is m

9条回答
  •  天涯浪人
    2020-12-05 06:21

    ok. I find another solution, and that is using the same method like this: add another dataSource and SessionFactory, next in the method of DAO that injject the sessionFactory add the @Qualifier anottation withe the property of the sessionFactory required, like this:

      @Autowired 
        public ProgramaSgteDAOHibernate(@Qualifier("sessionFactory3") SessionFactory sessionFactory) { 
         super(sessionFactory); 
        }
    

提交回复
热议问题