我想在执行之前或之后获取由grails生成的Mysql查询.
trainingList = PrivateTraining.findAll(query,parameter)
Run Code Online (Sandbox Code Playgroud)
我想打印由上述语句执行的完整的mysql查询.无论如何打印?
在您的DataSource.groovy:中设置此属性:
hibernate.show_sql=true
Run Code Online (Sandbox Code Playgroud)
例:
environments {
development {
dataSource {
/* ---------------------- */
hibernate.show_sql = true
/* ---------------------- */
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/my-db"
// ...
Run Code Online (Sandbox Code Playgroud)