Transaction.begin();
MedLog dbMed = factory.create(med.getMedId());
factory.copyInto(med,dbMed);
Transaction.commit();
}catch(DuplicateKeyException e){
throw new DAOException("A log medication belongs to " + med.getOwner() + "has already existed.");
}catch(RollbackException e){
throw new DAOException(e);
}finally{
if(Transaction.isActive()) Transaction.rollback();
}
}