-
Notifications
You must be signed in to change notification settings - Fork 31
Logging and debugging
Yuki Yoshinoya edited this page Feb 9, 2015
·
6 revisions
There are few ways of seeing the generated SQL
For example:
println(User.where(_.name like "john%").orderBy(_.age desc).toSql)
Using Logback, customize the xml configuration: (e.g.: src/main/resources/logback.xml)
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>
You will see every statements, and a dump of result sets of the seesion.
Add the following settings in build.sbt
or project/Build.scala
.
initialCommands in console := """
import com.github.aselab.activerecord._
import com.github.aselab.activerecord.dsl._
import models._
SomeTables.initialize
"""
> console
scala> User.forceInsertAll{ (1 to 10000).map{i => User("name" + i)} }
scala> User.where(_.name === "name10").toList