class Bar(var name: String) extends EntityWithGeneratedID[Long]
class Foo(var a: String, var b: Bar) extends EntityWithGeneratedID[Long]
val barId = 2l
transactional {
new Foo("something", lazyById[Bar](barId))
}
def reinitializeContext =
logInfo("reinitializing context " + contextName) {
clearCachedQueries
liveCache.reinitialize
storages.foreach(_.reinitialize)
reinitializeIdGenerators
unloadIndexes
}
I'm not sure how Grizzled logger works, but is the function block dependant on the log level?
object MyPostgresDriver extends PostgresDriver
with PgJson4sSupport
with array.PgArrayJdbcTypes {
/// for json support
override val pgjson = "jsonb"
type DOCType = text.Document
override val jsonMethods = org.json4s.native.JsonMethods
override lazy val Implicit = new Implicits with JsonImplicits
override val simple = new Implicits with SimpleQL with JsonImplicits {
implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
}
val plainImplicits = new Implicits with Json4sJsonPlainImplicits
}
override lazy val driver = MyPostgresDriver
object myContext extends ActivateContext with SlickQueryContext {
val storage = new PooledJdbcRelationalStorage {
val jdbcDriver = "org.postgresql.Driver"
val user = Some("postgres")
val password = None
val url = "jdbc:postgresql://127.0.0.1/json-test"
val dialect = postgresqlDialect
}
}
object myContext extends ActivateContext with SlickQueryContext {
override lazy val driver = MyPostgresDriver
val storage = new PooledJdbcRelationalStorage {
val jdbcDriver = "org.postgresql.Driver"
val user = Some("postgres")
val password = None
val url = "jdbc:postgresql://127.0.0.1/json-test"
val dialect = postgresqlDialect
}
}