Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从spring hibernate LocalSessionFactoryBean中分离映射资源_Java_Hibernate_Spring - Fatal编程技术网

Java 从spring hibernate LocalSessionFactoryBean中分离映射资源

Java 从spring hibernate LocalSessionFactoryBean中分离映射资源,java,hibernate,spring,Java,Hibernate,Spring,好的,我有这个spring hibernate xml配置 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mappingResources"> <l

好的,我有这个spring hibernate xml配置

<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>

com/abc/def/a.xml
com/abc/def/b.xml
com/abc/def/c.xml
org.hibernate.dialogue.mysqldialogue
假的
org.hibernate.cache.OSCacheProvider
真的
我已经在上面的xml配置中评论了这个问题

谢谢

您可以使用

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

类路径:com/abc/def/*.xml

这是工作!我将使用属性映射位置,然后使用类路径:com/abc/def/***.hbm.xml。谢谢