码迷,mamicode.com
首页 > 数据库 > 详细

格式化Hibernate的SQL输出语句

时间:2016-05-22 00:27:32      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:

在 applicationContent.xml 文件中加入以下程序代码,及可以Console中看到 hibernate 执行sql 语句

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver">
        </property>
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/pecope">
        </property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.use_sql_comments">false</prop>
            </props>
        </property>
        <property name="annotatedClasses">
            <list>
                <value>com.zbb.entity.Salesman</value>
                <value>com.zbb.entity.Plan</value>
                <value>com.zbb.entity.Schedule</value>
                <value>com.zbb.entity.Room</value>
                <value>com.zbb.entity.Customer</value>
                <value>com.zbb.entity.Message</value>
                <value>com.zbb.entity.Material</value>
                <value>com.zbb.entity.Project</value>
                <value>com.zbb.entity.Bargain</value>
                <value>com.zbb.entity.Plan2</value>
            </list>
        </property>
    </bean>

格式化Hibernate的SQL输出语句

标签:

原文地址:http://www.cnblogs.com/super-admin/p/5515882.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!