2011-09-09 45 views
3

好吧,我今年春天的hibernate xml配置。單獨映射來自spring hibernate的資源LocalSessionFactoryBean

<bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
    <property name="dataSource" ref="dataSource" /> 
    <property name="mappingResources"> 
     <list> 
      <value>com/abc/def/a.xml</value> 
      <value>com/abc/def/b.xml</value> 
      <value>com/abc/def/c.xml</value> 
      <!-- 
      And so on, about 50 xml for example 
      How can I separate list value above into 5 file for example? 
      ex I have h1.xml (or h1.txt) that contain 
      <value>com/abc/def/a.xml</value> 
      <value>com/abc/def/b.xml</value> 
      I have h2.xml (or h2.txt) that contain 
      <value>com/abc/def/c.xml</value> 
      <value>com/abc/def/d.xml</value> 
      so the mappingResources just read from the files (more than 1) than contain all mapping objects 
      --> 
     </list> 
    </property> 
    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> 
      <prop key="hibernate.show_sql">false</prop> 
      <prop key="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</prop> 
      <prop key="hibernate.cache.use_query_cache">true</prop> 
     </props> 
    </property> 
</bean> 

我已經在上面的xml配置中評論了這個問題。

感謝

回答

8

你可以使用

<property name="mappingLocations"> 
     <list> 
      <value>classpath:com/abc/def/*.xml</value> 
     </list> 
    </property> 
+0

它的工作!我使用屬性mappingLocations,然後使用classpath:com/abc/def/**/*。hbm.xml。謝謝! – Jef

相關問題