Take the 2-minute tour ×

I'm currently trying to move part of the SELECT query from the main DB to our read only replica. These queries are mostly used for stats and things like that and as stated are all read only.

I added to my application.conf the replica db, and modified the queries to use


Every time I make a call on the replica, Play! gives me the following error :

JPA error
A JPA error occurred (No JPAConfig is found with the name replica)

The only way I've found to prevent this error is to add some useless class with @PersistenceUnit(name="replica") on top of it to force the creation of the JPA conf for the replica.

I do believe this is more of a dirty hack than a clean fix, and since the replica DB is read only, creating on new table on it, even empty is quite annoying.

If anyone have found another way to fix this issue, I'll be really happy to hear about it !

Have a nice morning/evening/afternoon/night !

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I figured out another workaround, still not perfect but less messy than the previous.

The idea is to use


Instead of


If you already have some code expecting the List<Object[]> output of createNativeQuery(query).getResultList(); I made a quick function to transform the ResultSet you now receive :

public static List<Object[]> formatResult(ResultSet rs) {
    List<Object[]> resultList = new ArrayList<Object[]>();
    try {
        while(rs.next()) {
            Object[] array = new Object[rs.getMetaData().getColumnCount()];
                array[i] = rs.getObject(i+1);
    } catch (SQLException e) {
    return resultList;

I'm still testing this function on the whole part of our code that is getting swaped to the replica DB, I'll update if anything goes wrong with it.

share|improve this answer

Your Answer


