Reputation: 41193
Is it somehow possible to see the DDL produced when opening a EntityManagerFactory in JPA? I seem to be having some problems but no errors are produced. I don't see any sort of log file and no output is written to StdOut or StdErr. I have a log4j.properties in src/main/resources:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
log4j.logger.org.hibernate=debug
log4j.logger.org.hibernate.SQL=debug
log4j.logger.org.hibernate.engine.CascadingAction=debug
log4j.logger.org.hibernate.tool.hbm2ddl=debug
I'm not even sure if the file is recognized. Is there a way I can find that out? How can I get better insight into the actions of Hibernate and/or JPA? I basically have no output (except the System.out.println()'s in my program).
Upvotes: 1
Views: 1141
Reputation: 4111
Not that this solves your first question, but I always add mye applications name to the .ConversionPattern. That way I can quickly find out if the changes are applied, and log more than one application to the same file
log4j.appender.stdout.layout.ConversionPattern=MyApp1 - %d{ABSOLUTE} %5p %c{1}:%L - %m%n
Upvotes: 0
Reputation: 100706
To find out whether your log4j.properties file is picked up you can introduce a deliberate error into it (misspell ConsoleAppender
class name, for example). Log4j should either blow up or at least show an error in a console if the file is indeed picked up.
As far as DDL goes,I'm using Hibernate with Spring rather than JPA so YMMV, but:
Your best bet would be to take a look at EntityManagerFactory code to figure out where the script is executed and see if there's any logging going on around it; you would then know what package you need to configure in your log4j.properties
Upvotes: 0
Reputation: 13632
Try adding the following in your persistence.xml, within the persistence unit.
<properties>
<property name="hibernate.show_sql" value="true"/>
</properties>
Not too sure whether it will give you the info you're looking for but should give you some extra output.
Upvotes: 1