code: public Class<?> getClass(Object example) {
      if (example instanceof HibernateProxy) {
        HibernateProxy proxy = (HibernateProxy) example;
        LazyInitializer initializer = proxy.getHibernateLazyInitializer();
        SessionImplementor implementor = initializer.getSession();
  
        if (initializer.isUninitialized()) {
          try {
            // getImplementation is going to want to talk to a session
            if (implementor.isClosed()) {
              // Give up and return example.getClass();
              return example.getClass();
            }
          } catch (NoSuchMethodError ex) {
            // We must be using Hibernate 3.0/3.1 which doesn't have
            // this method
          }
        }
  
        return initializer.getImplementation().getClass();
      } else {
        return example.getClass();
      }
    }
docs: Hibernate makes {@link Class#getClass()} difficult ...
  
  @param example The class that we want to call {@link Class#getClass()} on
  @return The type of the given object