Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am having problems when loading hibernate mappings from multiple paths.

My Spring session factory is define as follows:

<beans>
  ...
  <bean id="sessionFactory" class="org.springframwork.orm.hibernate3.LocalSessionFactory">
  </bean>

  <property name="mappingLocations">
    <list>
      <value>classpath:/mapping/*.hbm.xml</value>
    </list>
  </property>

When I put my mappings Foo.hbm.xml and Bar.hbm.xml into the directory src/main/resources/mappings, then both mappings are found when Hibernate is initialized.

But when I put Foo.hbm.xml into the directory src/main/resources/mapping and Bar.hbm.xml into the directory src/test/resources/mapping, then only the latter mapping file can be found. Hibernate will fail with "cannot find mapping for Foo" error.

I can see that the mappings are copied to the directories target/classes/mapping and target/test-classes/mapping, so why cannot hibernate find both mapping files? I thought that "classpath:/mapping/*.hbm.xml" would find both target/classes/mapping and target/test-classes/mapping directories?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.