Hibernate Debugging

There are several different levels of Hibernate debugging. For a high level of information, you can enable debugging via log4j:

    log4j.logger.org.hibernate=debug

Otherwise, you can ask Hibernate to dump the SQL it is generating. This will appear with ? rather than actual values, unfortunately:

    Hibernate: update phone_number set phone_number=? [...]

To make this happen, edit hibernate.cfg.xml and find the hibernateProperties section. Set the show_sql property to "true":

    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>

See also: Enable MySQL Protocol Tracing.

HibernateDebugging (last edited 2008-07-09 06:21:44 by localhost)