问题
I am having an issue with PostgreSQL, while using Grails/GORM. I want to be able to figure out what the query is that is running. It is failing asking about a field that I do not have in the class, and I can not find in the db either, so I am wondering how to debug this.
Here is my exception:
ERROR: column this_.level_version does not exist Position: 123. Stacktrace follows: org.postgresql.util.PSQLException: ERROR: column this_.level_version does not exist Position: 123 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96) at grails.orm.PagedResultList.(PagedResultList.java:55) at at.TriviaController.list(script13759817432761717501241.groovy:15) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:186) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:69) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:679)
回答1:
You can specify logSql=true
in your Datasource.groovy. See docs.
来源:https://stackoverflow.com/questions/18133530/using-grails-postgresql-how-do-i-debug-the-gorm