0

I have some classes (Teacher, Student...) and I want to create objects from them with fields backed from more database sources in a configurable way. The information where the data source is for a particular class field can be different depending on deployment (configuration of the App). I want to have the information about database sources persisted as well. (I use Hibernate for persisting.)

Example of deployment 1:

  • Teacher.firstname should be persisted from LDAP
  • Teacher.lastname should be persisted from LDAP
  • Teacher.email should be persisted from PostgreSQL
  • Student.firstname should be persisted from PostgreSQL
  • Student.lastname should be persisted from LDAP
  • Student.email should be persisted from PostgreSQL

So there needs to be also information persisted in some DB that Teacher.firstname is backed in LDAP, Teacher.email in PostgreSQL etc.

Example of deployment 2:

  • Teacher.firstname should be persisted from PostgreSQL
  • Teacher.lastname should be persisted from PostgreSQL
  • Teacher.email should be persisted from PostgreSQL
  • Student.firstname should be persisted from PostgreSQL
  • Student.lastname should be persisted from LDAP
  • Student.email should be persisted from PostgreSQL

So there needs to be also information persisted in some DB that Teacher.firstname is backed in PostgreSQL, Student.lastname in LDAP etc.

I use Spring (not only) for DI and JPA (Hibernate) for persistency, but it's not so important. I am not looking for an answer how to configure 2 datasources in Spring/JPA, but rather how to design that problem generally.

fxmasa
  • 714
  • 1
  • 8
  • 14
  • Well there's this http://docs.spring.io/spring-ldap/docs/current/reference/ but that doesn't fix the issue of configurable deployments. You question is probably a bit broad. – Alan Hay Dec 15 '16 at 18:19
  • 1
    Possible duplicate of [Multiple database with Spring+Hibernate+JPA](http://stackoverflow.com/questions/1902997/multiple-database-with-springhibernatejpa) – xenteros Dec 15 '16 at 19:00

0 Answers0