Customer customer = ...
customer.setEmail( "test@acme.com" );
UnitOfWork unitOfWork = unitOfWorkFactory.currentUnitOfWork();
EntityManager entityManager = unitOfWork.entityManager();
entityManager.persist(entity);
entityManager.flush();
entityManager.refresh(entity);
entityManager.getTransaction().commit();