I want to configure my application to send & receive data from more than one DB. How do I configure my scala-lift application to do that ?

有帮助吗?

解决方案

Create another connection Identifier ( in Boot.scala in case of lift application, otherwise in any other class where you are configure the Database Connections ). It's just a simple object creation.

....
object SecondaryConnectionIdentifier extends ConnectionIdentifier {
  def jndiName: String = "Secondary"
}

Now, in the Mapper Classes , override the dbDefaultConnectionIdentifier for example.

.....
object Dummy extends Dummy with LongKeyedMetaMapper[Dummy] {
  override def dbTableName="dummy_table"
  override def  dbDefaultConnectionIdentifier = SecondaryConnectionIdentifier
}

that's it.

To configure your Schemifier accordingly, you can add the name of the newly created connectionIdentifier (SecondaryConnectionIdentifier in this case )

Schemifier.schemify(true, Schemifier.infoF _, SecondaryConnectionIdentifier,
                      <mapper-name1>,<mapper-name2>,...)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top