Multiple Databases with Play Framework 2.1.x Multiple Databases with Play Framework 2.1.x database database

Multiple Databases with Play Framework 2.1.x


Ok, your application.conf seems to be correct.

You may use the secondary server like this:

EbeanServer secondary = Ebean.getServer("secondary");secondary.find(User.class).findList();

Once you've got your secondary server, you may treat it just as you treat the Ebean singleton.


I had the same problem and I fixed it by specifying the server name at the Model.Finder level.

So in your case, in your User class, you should have something like :

public static Model.Finder<Long, User> find = new Finder<Long, User>("secondary", Long.class, User.class);


You can use both:

public static Model.Finder<Long, User> find = new Finder<Long, User>("secondary", Long.class, User.class);

and

Ebean.getServer("secondary");

But you have to use the save method with the server declaration on your entity

public void save(String server)

Without save() ebean uses the default server, even on your user-entity!