The difference between mappingresources, mappinglocations, mappingdirectorylocations and Mappingjarlocations _hibernate

Source: Internet
Author: User
Since spring integrates fairly well with the Hibernate profile Hibernate.cfg.xml, 
I've been using Spring's org.springframework.orm.hibernate.LocalSessionFactoryBean to replace the features of hibernate.cfg.xml files in my project Localsessionfactorybean has several properties for finding hibernate mapping files: mappingresources, Mappinglocations, Mappingdirectorylocations and mappingjarlocations Their differences: mappingresources: Specify classpath under specific mapping file name <property name= " Mappingresources "> <value>petclinic.hbm.xml </value> </property> mappinglocations: You can specify any file path, And you can specify the prefix: classpath, file, <property name= "mappinglocations" > <value>/web-inf/petclinic.hbm.xml </ value> </property> <property name= "Mappinglocations" > <value>classpath:/com/company/domain/pe Tclinic.hbm.xml </value> </property> can also be specified with wildcard characters, ' * ' to specify a file (path) name, ' * * ' to specify multiple file (path) names, such as: <property name= " Mappinglocations "> <value>classpath:/com/company/domainmaps/*.hbm.xml </value> </property> Top The configuration is that hbm.xml files under any maps path under the Com/company/domain package are loaded as map file mapPingdirectorylocations: Specifies the mapped file path <property name= "Mappingdirectorylocations" > <list> <value>web-i Nf/hibernatemappings</value> </list> </property> can also be classpath to point out <property name= " Mappingdirectorylocations "> <list> <value>classpath:/XXX/package/</value> </list> </ 
 Property> mappingjarlocations: Specifies that the loaded mapping file is in the jar file


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.