java开源框架应用技巧之spring配置文件中如果有多个.hbm.xml文件的话,无论是项目开发过程中还是维护过程中修改起来都会很麻烦切容易出错 收藏
问题描述:
在spring配置文件中如果有多个*.hbm.xml文件的话,无论是项目开发过程中还是维护过程中修改起来都会很麻烦切容易出错
这时我们可以把name="mappingResources"改为name="mappingDirectoryLocations",然后只需要配置*.hbm.xml文件所在目录就行了
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!--<property name="mappingResources">
<list>
<value>classpath:/com/crm/entity</value>
<value>com/crm/entity/BasDict.hbm.xml</value>
<value>com/crm/entity/CstActivity.hbm.xml</value>
<value>com/crm/entity/CstCustomer.hbm.xml</value>
<value>com/crm/entity/CstLinkman.hbm.xml</value>
<value>com/crm/entity/CstService.hbm.xml</value>
<value>com/crm/entity/SalChance.hbm.xml</value>
<value>com/crm/entity/SalPlan.hbm.xml</value>
<value>com/crm/entity/SysRight.hbm.xml</value>
<value>com/crm/entity/SysRole.hbm.xml</value>
<value>com/crm/entity/SysRoleRight.hbm.xml</value>
<value>com/crm/entity/SysUser.hbm.xml</value>
<value>com/crm/entity/VOrders.hbm.xml</value>
<value>com/crm/entity/VOrdersLine.hbm.xml</value>
<value>com/crm/entity/VProduct.hbm.xml</value>
<value>com/crm/entity/VStorage.hbm.xml</value>
</list>
</property>-->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/crm/entity</value>
</list>
</property>
<property name="hibernateProperties">
<value>
<!-- hibernate.dialect=org.hibernate.dialect.MySQLDialect -->
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.hbm2dll.auto=update
hibernate.show_sql=true
hibernate.format_sql=true
</value>
</property>
</bean>
分享到:
相关推荐
<?xml version="1.0" encoding="UTF-8"?> <!-- - Application context definition for JPetStore's business layer. - Contains bean references to the transaction manager and to the DAOs in - ...
..........\...\..\..\persist\Xiangmubiao.hbm.xml ..........\...\..\..\.......\Xiangmubiao.java ..........\...\..\..\server\server.java ..........\...\hibernate.cfg.xml ..........\...\struts.xml ...
* 创建hibernate.cfg.xml文件连接数据库,加载SysUserGroup.hbm.xml文件,放置src下 <property name="hibernate.connection.username">root <property name="hibernate.connection.password">root ...
<constant name="struts.counfiguraction.xml.reload" value="true"/> <!-- 指定浏览器输出的编码格式 --> <constant name="struts.il8n.encoding" value="utf-8"/> <!--将action内容放在package元素下,...
-- 这里在配成spring,下边也要写一个名为spring-servlet.xml的文件,主要用来配置它的controller --> 19. *.do</url-pattern> 20. </servlet-mapping> 21. <welcome-file-list> 22. <welcome-file>index.jsp...
WEB-INF下的applicationContext.xml为Spring的配置文件,struts-config.xml为Struts的配置文件,file-upload.jsp为文件上传页面,file-list.jsp为文件列表页面。 本文后面的章节将从数据持久层->业务层->Web层的...
<value>com/bean/Tuser.hbm.xml</value> <prop key="hibernate.dialect"> org.hibernate.dialect.OracleDialect <prop key="hibernate.show_sql">true ...
<value>com/mysteelsoft/entity/Employee.hbm.xml</value> <prop key="hibernate.show_sql">true <prop key="hibernate.format_sql">true <prop key="hibernate.dialect"> org....
比如你没法像hibernate那样直接传一个对象给它让他拆分成sql并保存起来,当然这也是可以理解的,毕竟它并没有要求你去写 hbm.xml 文件所以无法知道你哪些字段要映射,哪些不要等等。又比如JdbcTemplate 可以帮忙把一...
<prop key="hibernate.hbm2ddl.auto">update <value>com.sixth.**.model <!-- 事务配置 --> class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <!-...