I have an slsb holding my business logic, how do I use generics to change the following three methods into one generic method ? The first two are the same db, the third is a different database. Also do the methods require further annotation in relation to transaction ?
@PersistenceContext(unitName = "db")
private EntityManager myEntityManager;
@PersistenceContext(unitName = "db2")
private EntityManager myDB2EntityManager;
@TransactionAttribute(TransactionAttribute.Required)
public void crud(MyEntity myEntity) throws MyException {
myEntityManager.merge(myEntity);
}
public void crud(ADifferentEntity aDifferentEntity) throws MyException {
myEntityManager.merge(aDifferentEntity);
}
public void crud(DB2Entity db2Entity) throws MyException {
myDB2EntityManager.merge(db2Entity);
}
Many thanks in advance. Cheers!