I want know what are best practices for CRUD operations in Managed Bean.I created EntityManagerUtils class which contains CRUD methods and redirect value to EntityManager CRUD methods:@Statelesspublic class EntityManagerUtils implements Serializable {    @PersistenceContext(unitName = BlackBoxes)    private EntityManager entityManager;    public void persist(Object object) {        entityManager.persist(object);    }    public <T> T merge(T t) {        return entityManager.merge(t);    }    public void refresh(Object object) {        entityManager.refresh(object);    }    public void remove(Object object) {        if (!entityManager.contains(object)) {            object = entityManager.merge(object);        }        entityManager.remove(object);    }    public <T> T find(Class<T> clazz, Object object) {        return entityManager.find(clazz, object);    }}This class is Stateless bean which I inject to Managed Bean and can do:EntityManagerUtils.persist(object);EntityManagerUtils.merge(object);EntityManagerUtils.remove(object);For example my Managed Bean for Storage entity:@Named@SessionScopedpublic class StorageListViewModel implements Serializable {    @Inject    private EntityManagerUtils em;    @Inject    private StorageDAO storageDAO;    @Inject    @Select    private Event<Storage> storageSelectionEvent;    private TreeNode storageNode;    private Map<Long, TreeNode> idToStorageNodeMap;    private Storage selectedStorage;    @PostConstruct    public void postConstruct() {        initializationCategoryNode();    }    public void onRowEdit(RowEditEvent event) {        em.merge((Box) event.getObject());    }    public void removeBox(Box removingBox) {        em.remove(removingBox);        selectedStorage.getBoxes().remove(removingBox);    }    public void onStorageNodeSelect(NodeSelectEvent event) {        selectedStorage = (Storage) event.getTreeNode().getData();        storageSelectionEvent.fire(selectedStorage);    }    public void createStorage() {        Storage newStorage = new Storage(newStorageName);        newStorage.setAddress(newStorageAddress);        newStorage.setNote(newStorageNote);        em.persist(newStorage);        storageCreationEvent.fire(newStorage);        cleanCreationParam();        Notification.info( , String.format( '%s'  , newStorage.getName()));    }    public void removeSelectedStorage() {        em.remove(selectedStorage);        storageNode.getChildren().remove(idToStorageNodeMap.get(selectedStorage.getId()));    }    private void initializationCategoryNode() {        storageNode = new DefaultTreeNode(root, null);        idToStorageNodeMap = new HashMap<>();        List<Storage> storageList = storageDAO.getAllStorage();        for (Storage storage : storageList) {            addStorageNode(storage, false);        }    }    private void addCreatedStorage(@Observes @Create Storage createdStorage) {        addStorageNode(createdStorage, true);        setSelectedStorage(createdStorage);        storageSelectionEvent.fire(selectedStorage);    }    private void addStorageNode(Storage storage, boolean selected) {        TreeNode newStorageNode = new DefaultTreeNode(storage, storageNode);        idToStorageNodeMap.put(storage.getId(), newStorageNode);        if (selected) {            idToStorageNodeMap.get(selectedStorage.getId()).setSelected(false);            newStorageNode.setSelected(true);        }    }}This bean contains follow methods, whose used EntityManagedUtils:removeBoxcreateStorageremoveSelectedStorageFor more complex and specific operations for each entity has its own DAO, EJB Bean, for Storage entity:@Statelesspublic class StorageDAOImpl implements StorageDAO, Serializable {    @PersistenceContext(unitName = BlackBoxes)    private EntityManager em;    @Override    public List<Storage> getAllStorage() {        return em.createNamedQuery(Storage.GET_ALL_STORAGE, Storage.class).getResultList();    }}And what I am wanting know:Q1. Is it normal to go his own way using EntityManagerUtils? Q2. What problems can occur when call CRUD methods through my EntityManagerUtils?Q3. Is it better to put CRUD methods in DAO each entity?, this option I do not like because it would have to duplicate the code in many places.Q4. If Q3 is true, how best to avoid duplicating code for CRUD methods?
CRUD in Managed Bean
java;jpa;jsf