I didn't really found whats the right way to open Transactions across multiple DAOs in JPA/Hibernate. Could this be a way to do it? Or are there better solutions?
EntityManager em = createEntityManager(); //from EntityManagerFactory
UserDAO userDAO = new UserDAO(em);
AddressDAO addressDAO = new AddressDAO(em);
Address address = addressDAO.find(1);
address.setZIP("1234");
User user = userDAO.find(1);
EntityTransaction tx = em.getTransaction();
tx.begin();
addressDAO.save(address);
userDAO.delete(user);
tx.commit();
em.close();
Is it ok to create new DAOs for each Request?