code: @SuppressWarnings("unchecked")
      private T getAttached(T object) {
          if (entityManager.contains(object)) {
              return object;
          } else {
              return findOne((I) entityManager.getEntityManagerFactory()
                      .getPersistenceUnitUtil().getIdentifier(object));
          }
      }
docs: Gets the 'managed' version of the given entity instance.
  
  @param object the entity
  @return the managed version, it can be the given object is the instance is not detached. If we can't find the
  'managed' version of the object, return {@code null}.