`

如何在S2SH中, 由.hbm.xml文件和POJO类生成数据库表

阅读更多
首先要在spring.xml里面配置sessionfactory和其他的,sessionfactory里面要制定hbm.xml文件的位置

Java代码:
 
<bean id="sessionFactory" 
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
        <property name="dataSource"> 
            <ref bean="dataSource" /> 
        </property> 
        <property name="hibernateProperties"> 
            <props> 
                <prop key="hibernate.dialect"> 
                    org.hibernate.dialect.MySQLDialect 
                </prop> 
                <!-- 表示允许自动提交 --> 
                <prop key="hibernate.connection.autocommit">true</prop> 
                <!-- 显示sql语句 --> 
                <prop key="hibernate.show_sql">true</prop> 
                <prop key="hibernate.format_sql">true</prop> 
                <!--  自动生成表结构 
                <prop key="hibernate.hbm2ddl.auto">create</prop> 
                 --> 
            </props> 
        </property> 
        <property name="mappingDirectoryLocations"> 
            <list> 
                <value>classpath:/hibernate</value> 
            </list> 
        </property> 
    </bean> 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics