我有两个我想要存储对象的数据库,每个数据库都是互斥的
database1 for database1 dat2的object2
有没有办法自动“映射”或“指示”每个模型在进化过程中放入哪个数据库
答案 0 :(得分:0)
为了做到这一点,你将创建两个不同的数据库连接
db.default.driver="com.mysql.jdbc.Driver"
db.default.url="jdbc:mysql://localhost:3600/db_name1"
db.default.user="username"
db.default.password="password"
db.otherDBName.driver="com.mysql.jdbc.Driver"
db.otherDBName.url="jdbc:mysql://localhost:3306/db_name2"
db.otherDBName.user="username"
db.otherDBName.password="password"
//then you let ebean know where to find the models
ebean.default="models.*"
ebean.otherDBName="otherDB.models.*"
//you can refer to the otherDBName with
Ebean.getServer("otherDBName").save(object);