The way I did it was to have an additional resource directory in the Maven Oracle profile, so as to allow the base abstract test class to include a bean definition file spring-hibernate-custom-dao.xml containing some Oracle specific DAO:
Code:
<bean id="navbarLanguageCustomDao"
class="com.thalasoft.learnintouch.core.dao.oracle.hibernate.NavbarLanguageCustomHibernateDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
The custom DAO is as follows:
Code:
public interface NavbarLanguageCustomDao extends GenericDao<NavbarLanguage, Serializable> {
public List<NavbarLanguage> findWithNavbar(Navbar navbar);
}
Code:
@Repository
@Transactional
public class NavbarLanguageCustomHibernateDao extends
GenericHibernateDao<NavbarLanguage, Serializable> implements
NavbarLanguageCustomDao {
@SuppressWarnings("unchecked")
public List<NavbarLanguage> findWithNavbar(Navbar navbar) {
String statement = "select id, version, language_code as languageCode from navbar_language where navbar_id = :navbarId order by language_code nulls first";
Query query = getSession().createSQLQuery(statement)
.addScalar("id", StandardBasicTypes.INTEGER)
.addScalar("version", StandardBasicTypes.INTEGER)
.addScalar("languageCode");
query.setInteger("navbarId", navbar.getId());
return query.setResultTransformer(Transformers.aliasToBean(NavbarLanguage.class)).list();
}
}
And it is included in the base test class with the annotation:
Code:
@ContextConfiguration(locations = { "classpath:spring-hibernate.xml", "classpath:spring-hibernate-custom-dao.xml", "classpath:spring-hibernate-dao.xml", "classpath:spring-data-source.xml", "classpath:log4j.xml" })
public abstract class AbstractDaoTest extends AbstractTransactionalJUnit4SpringContextTests {
}