Spring configuration skills for hibernate configuration files (reproduced...)

mappingLocations, mappingDirectoryLocations and mappingJarLocations difference

due to the spring to hibernate configuration file hibernate.cfg. xml integration is quite good,
so, in a project I have been using spring org.springframework.orm.hibernate.LocalSessionFactoryBean to replace hibernate.cfg. xml file Function
LocalSessionFactoryBean has several properties to find hibernate mapping files:
the difference between mappingResources, mappingLocations, mappingDirectoryLocations and mappingJarLocations :
mappingResources: specify the specific mapping file name under the classpath
<property name="mappingResources">
    <value>petclinic. hbm . Xml < /value>
</property>
mappingLocations: You can specify any file path, and you can specify the prefix: classpath ,file etc.
<property name="mappingLocations">
    <value>/WEB-INF/petclinic. hbm . xml </value>
</property>

<property name="mappingLocations">
    <value> classpath :/com/company/domain /petclinic. hbm . xml </value>
</property>
can also be specified by wildcards,'*' specifies a file (path) name, and'**' specifies multiple file (path) names, for example:
<property name= "mappingLocations">
    <value> classpath :/com/company/domain/**/maps/*. hbm . xml </value>
</property>
The above configuration is at any maps path com / company / domain package HBM . XML files are loaded to the mapping file

mappingDirectoryLocations: specify the file path
of the mapping mappingJarLocations: specify the loaded mapping file in the jar file

Guess you like

Origin blog.csdn.net/geggegeda/article/details/4203143