0

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)

nycynik
  • 7,371
  • 8
  • 62
  • 87

1 Answers1

2

You can specify logSql=true in your Datasource.groovy. See docs.

Gregg
  • 34,973
  • 19
  • 109
  • 214
  • That helped me find this: http://grails-dev.blogspot.com/2013/06/how-to-log-sql-statements-in-grails.html – nycynik Aug 08 '13 at 18:56
  • If you want to see it formatted add format_sql=true in hibernate block too. –  Aug 08 '13 at 18:59