You can use different net.liftweb.mapper.ConnectionIdentifiers to represent different DBs. Then there are MetaMapper methods that take ConnectionIdentifiers to tell it which connection to use. For example, in Boot you can do:
object FirstDB extends ConnectionIdentifier { def jndiName = "First" }
object SecondDB extends ConnectionIdentifier {def jndiName = "Second" }
object MyConnectionManager extends ConnectionManager {
def newConnection (name : ConnectionIdentifier) = name match {
case FirstDB => // open a connection for your first DB
case SecondDB => // open a connection for the second DB
}
...
}
def boot {
DB.defineConnectionManager(FirstDB, MyConnectionManager)
DB.defineConnectionManager(SecondDB, MyConnectionManager)
...
}
Then in your code you can do things like:
User.findAllDb(FirstDB)
or, more useful, you can set the connection identifier on a per-entity basis using dbDefaultConnectionIdentifier on the MetaMapper:
object Widget extends Widget with MetaMapper[Widget] {
override def dbDefaultConnectionIdentifier = FirstDB
}
object Gizmo extends Gizmo with MetaMapper[Gizmo] {
override def dbDefaultConnectionIdentifier = SecondDB
}
Derek