Hey guys, my goal is create an EntityManager using properties dependent on which database is in use. I've seen something like this done in all my Google searches(I made the code more basic for the purpose of this question):
@PersistenceUnit
private EntityManagerFactory emf;
private EntityManager em;
private Properties props;
@PostConstruct
public void createEntityManager(){
//if oracle set oracle properties else set postgres properties
emf = Persistence.createEntityManagerFactory("app-x");
em = emf.createEntityManager(props);
}
This works and I can load Oracle or Postgres properties successfully and I can Select from either database. HOWEVER, I am running into issues when doing INSERT statements. Whenever an INSERT is done I get a duplicate primary key exception.. every time! Can anyone shed some light on why this may be happening? Thanks -Brad