mappingResources,annotatedClasses(映射)

这两个是有本质区别的,光看名字也能看出来,哈哈,好了,入正题:

mappingResources用于指定少量的hibernate配置文件像这样

Xml代码 

1
2
3
4
5
6
7
<property name="mappingResources"
     <list> 
               <value>WEB-INF/conf/hibernate/cat.hbm.</value> 
                <value>WEB-INF/conf/hibernate/dog.hbm.</value> 
                ......  
      </list> 
</property>

 

就这样一个一个的写呗,当你觉得麻烦的时候,找mappingDirectoryLocations来就行了

Xml代码 

1
2
3
4
5
<property name="mappingDirectoryLocations"
       <list> 
    <value>WEB-INF/conf/hibernate</value> 
       </list> 
</property>

 

通过注解的方式:

1
2
3
<property name="annotatedClasses"
   <list><value>com.systop.common.core.dao.testmodel.TestDept</value></list> 
</property>
原文地址:https://www.cnblogs.com/toSeeMyDream/p/5537835.html