I want to create tables with scala-activerecord:
Tables.initialize(ConfigFactory.load(env))
This does not work, because initialize
accepts only Map[String, Any]
.
My second try was:
Tables.initialize(ConfigFactory.load(env).root())
where root()
returns ConfigObject
:
public interface ConfigObject extends ConfigValue, Map<String, ConfigValue>
I still get:
Error:(15, 49) type mismatch;
found : com.typesafe.config.ConfigObject
required: Map[String,Any]
Tables.initialize(ConfigFactory.load(env).root())
^
I don't get it, Any
should accept any value, why it does not accept ConfigValue
?
How can I pass my config to the Tables.initialize
method?
How can I pass my config to the Tables.initialize method?
This might be a solution:
import scala.collection.JavaConversions._
Tables.initialize(ConfigFactory.load(env).root.unwrapped.toMap)
For ActiveRecordTables#initialize
method, it is assumed that you give the override settings and values as follows:
Tables.initialize(Map(
"driver" -> "org.postgresql.Driver",
"jdbcurl" -> "jdbc:postgresql://hostname:5432/dbname"
))
This feature is supposed to be used for applications such as temporarily overrides the value set (e.g. Coding tests).
For database settings, please refer to the following:
https://github.com/aselab/scala-activerecord/wiki/Database-Settings