Разница между объектом, полученным EntityManager Find () и параметром, переданным в методы? - PullRequest
0 голосов
/ 04 декабря 2018

Я работаю над назначением ресторана

В классе RestaurantManager я кодирую методы CRUD

Скажем, у меня есть следующий метод

public Restaurant updateRestaurant(Restaurant restaurant) {
    //get emf from a singleton supplier
    EntityManagerFactory emf = EMFSupplier.getInstance().getEMF();
    EntityManager em = emf.createEntityManager();

    Restaurant restaurantToBeUpdated = (Restaurant)em.find(Restaurant.class, restaurant.getRestaurantId);


    // Here's my question
    Set<Chefs> chefsFirstSet = restaurantToBeUpdated.getAllChefs();
    Set<Chefs> chefsSecondSet = restaurant.getAllChefs();

    //Both retrieve a set of chefs, one use Restaurant from em.find(), 
    //the other use "restaurant" parameter passed to this method

    What's the difference between this two sets?

}
...