Play 1.3.X use multy datasouce question

play-1

(Shilg) #1

I want add another datasource like this :

db.default.url=jdbc:mysql://10.10.13.138:3306/test?characterEncoding=UTF-8
db.default.driver=com.mysql.jdbc.Driver
db.default.user=root
db.default.pass=root

db.readDB.url=jdbc:mysql://10.10.13.131:3306/test?characterEncoding=UTF-8
db.readDB.driver=com.mysql.jdbc.Driver
db.readDB.user=root
db.readDB.pass=123456

I use readDB like this:
Query query=JPA.em("readDB ").createNativeQuery(sql,ProductListParam.class);
The exception is :
unknow entity ProductListParam

I try the config jpa.readDB.entities,but nothing difirent as before, how can I load the entity to the added datasouce(readDB)? I use paly 1.3


(Johan Vosloo) #2

Did you remember to annotate the entity with the persistence unit?

E.g.:

@Entity
@PersistenceUnit(name="readDB")
@Table(name = "my_entity")
public class MyEntity extends Model {
...
}