public T update(long id, T entity){
        T oldEntity = read(id);
        if(oldEntity != null){
            merge(oldEntity, entity);
            entity.setId(id);
        }

        return entityManager.merge(entity);
    }