I haven't been able to get any more console output (to help with debugging) from Hibernate despite setting a few properties in the hibernate.cfg.xml
file. For example, adding the line <property name="show_sql">true</property>
did not, in fact, show SQL statements in the console.
I've also tried playing around with the contents of the log4j.properties
file - like setting log4j.logger.org.hibernate=debug
- with no luck. What am I missing?
Edit: the contents of the hibernate-service.xml file are
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate_SMS">
<attribute name="DatasourceName">java:/SMS_DS</attribute>
<attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
</mbean>
</server>
I'm not 100% sure if this actually has any effect, though. That XML file is in the Eclipse project that handles my database stuff, but doesn't seem to be in the JBoss deploy directory.
Edit 2: This is definitely deployed as a HAR. That said, I'm pretty sure that I need hibernate.cfg.xml
- I recall having problems when a mapping document was omitted as an entry in that file. I think the HAR is generated using ant - there's a target for it in the build.xml file:
<target name="har" depends="prepare" description="Builds the Hibernate HAR file">
<mkdir dir="${class.root}" />
<mkdir dir="${distribution.dir}" />
<jar destfile="${distribution.dir}/${har.name}">
<!-- include the hbm.xml files -->
<fileset dir="${class.root}">
<include name="**/*.hbm.xml"/>
<include name="com/[redacted]/sms/data/dto/*.class"/>
<include name="com/[redacted]/sms/data/dto/base/*.class"/>
</fileset>
<!-- include jboss-service.xml -->
<metainf dir="${hibernate.dir}">
<include name="hibernate-service.xml"/>
</metainf>
</jar>
</target>
but when I do the ant build with incorrectly-formed xml in the hibernate-service.xml file, it doesn't fail. Update Even deleting the file entirely doesn't cause a build to fail. Any ideas here? End Update
It sounds like getting Hibernate to output SQL statements should (if everything's set up correctly) take care of it entirely - does that mean that the settings in log4j.properties won't make a difference here? - because that actually does change the output when running ant.
Edit 3: After running into other weird issues with my data har
, I deleted the har file entirely and rebuilt it using the har
ant build target. Suddenly everything's working! Thanks to chessplay for his awesome helpfulness. Can't say I know exactly what did it in the end, but I'd rather acknowledge his efforts than write and accept my own answer; My apologies if you're not a "he."