你说的配成多个文件是把哪个文件配成多个呀,你要是只觉得hibernate的映射文件太多,不想放spring的XML里可以用hibernate自己的XML也是一样的

解决方案 »

  1.   

    用<property name="mappingDirectoryLocations">
        <list>
           <value>classpath:.....</value>
        </list>
      </property>
      

  2.   

    我想把hibernate的or映射文件的配置部分分成多个文件放在ApplicationContex.xml外面,楼上的能不能具体点。。<value>classpath:.....</value>是配置路径还是hbm.xml?
      

  3.   

    Spring:
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation">
    <value>classpath:hibernate.cfg.xml</value>
    </property>
    </bean>Hibernate:
    <mapping resource="com/xxx0.hbm.xml" />
    <mapping resource="com/xxx1.hbm.xml" /><mapping resource="com/xxx2.hbm.xml" /><mapping resource="com/xxx3.hbm.xml" />
      

  4.   

    我怎么把
    <mapping resource="com/xxx0.hbm.xml" />
    <mapping resource="com/xxx1.hbm.xml" /><mapping resource="com/xxx2.hbm.xml" /><mapping resource="com/xxx3.hbm.xml" />
    分成多个部分?放到多个文件中?
      

  5.   

    classpath:....  是你文件的路径
      

  6.   

    比如:
    <property name="mappingDirectoryLocations">
        <list>
           <value>classpath:/com/myconf/</value>
        </list>
    </property>
      

  7.   

    恩这样写就行
    <property name="mappingDirectoryLocations">
        <list>
           <value>classpath:/com/myconf/</value>
        </list>
    </property>
      

  8.   

    <property name="mappingDirectoryLocations">
    <list>
    <value>classpath:/com/myconf/</value>
    </list>
    </property>
    classpath:/com/myconf/ 是什么?里面是什么东西
    我怎么把原来的
    <mapping resource="com/xxx0.hbm.xml" />
    <mapping resource="com/xxx1.hbm.xml" /><mapping resource="com/xxx2.hbm.xml" /><mapping resource="com/xxx3.hbm.xml" />
    分成多个部分?放到多个文件中?各位大哥能具体点不?
      

  9.   

    classpath里面就是你的那些xxx.hbm.xml文件
      

  10.   

    classpath里面就是你的那些xxx.hbm.xml文件
    可是我的那些xxx.hbm.xml文件在不同的包下面啊<list>
    <value>classpath:/com/myconf/</value>
    </list>
    这个value是path?
    有没有高手给个详细的配置
      

  11.   

    给楼主看看我的配置方法
    Spring
    .....
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
        <ref bean="dataSource"/>
      </property>
      <property name="configLocation">
        <value>/WEB-INF/hibernate.cfg.xml</value>
      </property>
      </bean>
    .....hibernate.cfg.xml
    .....
    <mapping resource="com/zqp/test/pojo/Dept.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Income.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Cost.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Admin.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Player.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Coach.hbm.xml"/>
    ....
      

  12.   

    谢谢楼上的,但是我现在要把这些东西分成多块放在不同的文件里面怎么做?.....
    <mapping resource="com/zqp/test/pojo/Dept.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Income.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Cost.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Admin.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Player.hbm.xml"/>
    <mapping resource="com/zqp/pojo/Coach.hbm.xml"/>
    ....
      

  13.   

    我怎么看不太明白你们写的,不就是写两个XML文件?
      1) Model.hbm.xml
      2) hibernate.cfg.xml
    里面也不是那样写的呀?
      

  14.   

    我怎么看不太明白你们写的,不就是写两个XML文件?
    1) Model.hbm.xml
    2) hibernate.cfg.xml
    里面也不是那样写的呀?
    1) Model.hbm.xml 这是or映射的文件
    2) hibernate.cfg.xml 这是hibernate的配置文件,里面指定了一批or映射,我想把这一批又分成多个部分。
      

  15.   

    分成多块的话
     <property name="configLocation">
        <value>/WEB-INF/hibernate.cfg.xml</value>
      </property>
    改成
     <property name="configLocation">
        <value>/WEB-INF/hibernate.cfg.xml,/XXX/XXX/XXX.cfg.xml</value>
      </property>
      

  16.   

    谢谢zqpsswh(似水无痕) 好像这是我想要的。
      

  17.   

    <property name="mappingDirectoryLocations">
        <list>
           <value>classpath:/com/myconf/</value>
           <value>classpath:/com/myconf2/</value>
           ....
        </list>
    </property>
    这里/com/myconf/,/com/myconf2就是你放xxx.hbm.xml的目录
      

  18.   

    用spring的配置文件就可以了,不用再去写hibernate.cfg.xml了
      

  19.   

    谢谢 Daem0n(瓶中的精灵) 
    我的意思是把
    <value>classpath:/com/myconf/</value>
    <value>classpath:/com/myconf2/</value>
    ....
    这些配置放在不同的文件中,不是spring的xml中,因为太多了。
      

  20.   

    楼主的意思不就是觉得xxx.hbm.xml太多了,在spring里面写:
    <mapping resource="com/xxx0.hbm.xml" />
    <mapping resource="com/xxx1.hbm.xml" />
    <mapping resource="com/xxx2.hbm.xml" />
    <mapping resource="com/xxx3.hbm.xml" />
    太麻烦吗?
      

  21.   

    据说可以
    domain/*/*.hbm.xml使用通配符,不过要求把hbm放到一个文件夹下