code: @Override
      public T remove(T entity) {
          EntityManager entityManager = getEntityManager();
          if (entityManager.contains(entity)) {
              entityManager.remove(entity);
          } else {
              entityManager.remove(entityManager.merge(entity));
          }
          return entity;
      }
docs: Deletes an entity from the database. It calls
  {@link EntityManager#remove(java.lang.Object) } and throws the same
  exceptions.
  
  @param entity the entity to delete.
  
  @return the deleted entity.