I'm making putting together a system that does the basic job of persisting hibernate POJOs into a database. We've got a bit of a legacy system in place at the moment where the older POJOs are generated by hbm.xml files, but the new POJOs are just annotated classes.
this is my hibernate.cfg.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
<!-- Database connection settings HSQL DB -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:mem:test</property>
<property name="connection.username">sa</property>
<property name="connection.password" />
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hbm2ddl.auto">create-drop</property>
<property name="show_sql">true</property>
<property name="show_comments">true</property>
<property name="hibernate.connection.pool_size">0</property>
<mapping resource="com/dto/Address.hbm.xml" />
<mapping class="com.dto.Customer"/>
</session-factory>
</hibernate-configuration>
This is ok except when it comes time to Unit testing and it appears that having both a resource and a class mapping in the cfg.xml file seems to break unit tests at build time.
<mapping resource="com/dto/Address.hbm.xml" />
<mapping class="com.dto.Customer"/>
Is there a way round this? Can I even use the 2 differnt mapping types in a hibernate.cfg.xml file?