Hi,
I don't know if this really is a maven issue but could you isolate the
db spesific stuff into their own classes and then use spring to inject
the desired bean per configuration.
I'm not a spring expert so there might be simpler ways to achive this
but something along the lines
The spring-hibernate-dao-mysql.xml file content:
<beans>
<bean id="addressDao"
class="com.thalasoft.learnintouch.core.dao.hibernate.AddressHibernateDao">
<property name="sessionFactory" ref="sessionFactory" />
<property name="nativeAdapter" ref="addressMysqlNativeBean" />
</bean>
<bean id="addressMysqlnativeBean" .... </bean>
</beans>
and for hsqldb you would have spring-hibernate-dao-hsqldb.xml with <bean
id="addressHsqldbNativeBean" /> that you could use with your tests.
br,
Samuli
On 23.11.2012 8:15, Stephane-3 wrote:
Hi,
I have a Spring Hibernate project with a DAO coded against a MySql database.
Most of the DAO methods would run on HSQLDB and on Oracle, except for some
that contain database server specific syntax.
I already use some Maven profiles to filter the database server data source
specific properties.
Now I wonder which way to go so as to have a few DAO methods specific to
each database server.
I would like to keep most of the DAO methods in a common location, and only
have the database server specific DAO methods in anpther one.
So for example, for the Oracle database server:
Should the Oracle specific DAO methods sit in a different Java package ?
Should there be a different resource xml file to have the beans for the
integration tests injection of these specific DAO methods ?
Here is my setup as of today:
The abstract test class:
@ContextConfiguration(locations = { "classpath:spring-hibernate.xml",
"classpath:spring-hibernate-dao.xml", "classpath:spring-data-source.xml",
"classpath:log4j.xml" })
public abstract class AbstractDaoTest extends
AbstractTransactionalJUnit4SpringContextTests {
}
A Maven profile for the Oracle database server:
<profile>
<id>oracle-test</id>
<properties>
<test.source.dir>src/integration/java</test.source.dir>
</properties>
<build>
<filters>
<filter>src/integration/filters/data-source.oracle.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/integration/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
The spring-hibernate-dao.xml file content:
<beans>
<bean id="addressDao"
class="com.thalasoft.learnintouch.core.dao.hibernate.AddressHibernateDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="adminDao"
class="com.thalasoft.learnintouch.core.dao.hibernate.AdminHibernateDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
etc...
</beans>
--
View this message in context:
http://maven.40175.n5.nabble.com/DAO-injection-in-integration-tests-with-a-few-database-server-specific-methods-tp5732576.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--
Remion Oy Etävalvontajärjestelmät liiketoiminnan
Samuli Saarinen tehostamiseen
gsm +358 (0)50 3560075
fax +358 (0)3 2125064 www.remion.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]