Spring hibernate configuration in Mappinglocations, Mappingdirecto

Source: Internet
Author: User

Mappinglocations, mappingdirectorylocations, and mappingjarlocations differences
Since spring's integration of Hibernate profile Hibernate.cfg.xml is pretty good,
so, In the project I have been using spring's org.springframework.orm.hibernate.LocalSessionFactoryBean to replace the functionality of the Hibernate.cfg.xml file
Localsessionfactorybean has several properties to look up hibernate mapping files: mappingresources, Mappinglocations, Mappingdirectorylocations and Mappingjarlocations
Their differences:
Mappingresources: Specify a specific map file name under Classpath

Petclinic.hbm.xml

Mappinglocations: You can specify any file path, and you can specify a prefix: classpath, file, and so on

/web-inf/ Petclinic.hbm.xml


Classpath:/com/company/domain/petclinic.hbm.xml

can also be specified with a wildcard character,???? *???? Specify a file (path) name,???? **???? Specify multiple file (path) names, for example:

Classpath:/com/company/domain/**/maps/*.hbm.xml

The configuration above is in the com/company/ The Hbm.xml file under any maps path under the domain package is loaded as a mapping file
Mappingdirectorylocations: Specifies the mapped file path
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.