解决方案 »

  1.   

    请过了,我把Tomcat下webapps下我的项目删除,再删除work目录下所有的文件,再重新部署,还是不行,数据可以插入数据库,也可以拿出来,就是不输出,太郁闷了!
      

  2.   

    你写丢了应该是 <property name="hibernate.show_sql">true</property>
      

  3.   

    你说的是对的,但是
    <property name="hibernate.show_sql">true</property><property name="hibernate.show_sql">TRUE</property>
    这两个属性其实效果是一样的,所以还是没有解决问题,不过还是谢谢你!
      

  4.   

    会不会是程序有问题,根本没执行sql所以看不见...
      

  5.   

    改为<property name="dialect">
    org.hibernate.dialect.MySQL5Dialect
    </property>
    5.X之前的方言不行。
      

  6.   

    对比下,有没有什么区别呢<?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory>
            <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
            <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="hibernate.connection.password">password</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/mkyong</property>
            <property name="hibernate.connection.username">root</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
            <property name="show_sql">true</property>
            <property name="format_sql">true</property>
            <property name="use_sql_comments">true</property>
        </session-factory>
    </hibernate-configuration>
    http://www.mkyong.com/hibernate/hibernate-display-generated-sql-to-console-show_sql-format_sql-and-use_sql_comments/
      

  7.   

    确实是我自己太大意了,我忘记了我是用Spring对Hibernate进行管理的,所以这些属性的配置应该是在ApplicationContext.xml中进行配置,而我之前一直把目光盯在Hibernate.cfg.xml配置文件中,当然找不到问题的所在,今天配置另个对象的时候我才突然觉悟了,哎!根本不是问题的问题搞了我好几天!
      

  8.   

    楼主,我也是和你一样的问题啊,我一开始就是用spring管理的呀,但是<bean id="SessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="datasource"></property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    <prop key="show_sql">true</prop>
    <prop key="format_sql">true</prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>  ....还是一样的,没半毛钱用处...你的竟然可以解决...我心里很不平衡,这果断朩有情啊...