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
I had this same problem. I have solved this by creating: applicationContext.xml
${mySql.dialect}
classpath:hibernate.cfg.xml
${oracle.dialect}
classpath:hibernate.cfg.xml
in Dao injected sessionFactory with Qualifier annotation. In my case I had generic BaseEnity:
public abstract class BaseEntityDAOImpl implements BaseEntityDAO {
private Class persistentClass;
@Autowired
@Qualifier("oracleSessionFactory")
SessionFactory sessionFactory;
}
and in service bean using annotation:
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = true, value = "oracleTransactionManager")
public class UserService {
@Autowired
private UserDAO dao;
}
Averythings wokrs fine.