通过EntityManager Find()检索的对象与传递给方法的参数之间的区别?

时间:2018-12-04 17:14:45

标签: java sql database entitymanager

我正在做餐厅任务

在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?

}

0 个答案:

没有答案