zoukankan      html  css  js  c++  java
  • [转]hibernate之maping映射-mappingResources、mappingLocations、mappingDirectoryLocations、mappingJarLocations

    mappingResources、mappingLocations、mappingDirectoryLocations、mappingJarLocations的区别:
    1. mappingResources:指定classpath下具体映射文件名

    <property name="mappingResources">   
        <value>petclinic.hbm.xml</value>     
    </property>

    2. mappingLocations:可以指定任何文件路径,并且可以指定前缀:classpath、file等

    <property name="mappingLocations"> 
    <value>/WEB-INF/petclinic.hbm.xml</value> 
    </property> 
    <property name="mappingLocations"> 
    <value>classpath:/com/company/domain/petclinic.hbm.xml</value> 
    </property>

    也可以用通配符指定,'*'指定一个文件(路径)名,'**'指定多个文件(路径)名,例如:

    <property name="mappingLocations"> 
    <value>classpath:/com/company/domainmaps/*.hbm.xml</value> 
    </property>

    上面的配置是在com/company/domain包下任何maps路径下的hbm.xml文件都被加载为映射文件

    3. mappingDirectoryLocations:指定映射的文件路径

    <property name="mappingDirectoryLocations"> 
    <list> 
    <value>WEB-INF/HibernateMappings</value> 
    </list> 
    </property>

    也可以通过classpath来指出

    <property name="mappingDirectoryLocations"> 
    <list> 
    <value>classpath:/XXX/package/</value> 
    </list> 
    </property>

    mappingJarLocations 用于加载jar包中的映射文件:

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

    原文:http://wukaxi.iteye.com/blog/1401753 

     
  • 相关阅读:
    mybatis:mybatis再总结
    shiro:RememberMe
    shiro:session管理
    shiro:缓存管理
    shiro:授权管理
    shiro:密码加密(加密、加盐加密)
    spring:spring再总结(ioc、aop、DI等)
    SpringBoot:整合layui、退出功能
    layui:内置模块(日期与时间、数据表格)
    nuxtjs中配置配置env
  • 原文地址:https://www.cnblogs.com/Jxiaobai/p/6866167.html
Copyright © 2011-2022 走看看