Hello everybody
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 my code with one datasource, that run perfectly, but i don't know how add another datasource.
HIBERNATE CONFIGURACION
Code:<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url" value="jdbc:mysql://localhost/personal"/> <property name="username" value="root"/> <property name="password" value="mysql"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource"/> </property> <property name="packagesToScan"> <list> <value>com.app.personal.model</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">false</prop> </props> </property> </bean> <tx:annotation-driven/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean>
DAO EXAMPLE
Code:@Repository public class ModuloDAOHibernate extends HibernateTemplate implements ModuloDAO { @Autowired public ModuloDAOHibernate(SessionFactory sessionFactory) { super(sessionFactory); } public List<Modulo> getAllGrupoModuloDAO() { Criteria criteriaList = this.getSession().createCriteria(Modulo.class); criteriaList.addOrder(Order.asc("orden")); return criteriaList.list(); }
Thanks



Reply With Quote
