code: public static boolean areBeansEqual( Object bean1, Object bean2 )
    {
      if( bean1 == bean2 )
      {
        return true;
      }
  
      if( bean1 == null || bean2 == null )
      {
        return false;
      }
  
      IType class1 = TypeLoaderAccess.instance().getIntrinsicTypeFromObject( bean1 );
      IType class2 = TypeLoaderAccess.instance().getIntrinsicTypeFromObject( bean2 );
      if( class1.isAssignableFrom( class2 ) || class2.isAssignableFrom( class1 ) )
      {
        return bean1.equals( bean2 );
      }
  
      if( CommonServices.getEntityAccess().isDomainInstance( bean1 ) ||
          CommonServices.getEntityAccess().isDomainInstance( bean2 ) )
      {
        return CommonServices.getEntityAccess().areBeansEqual( bean1, bean2 );
      }
  
      return bean1.equals( bean2 );
    }
docs: Test for equality between two BeanType values. Note this method is not entirely appropriate for
  non-BeanType value i.e., it's not as intelligent as EqualityExpression comparing primitive types,
  TypeKeys, etc.
  <p/>
  Msotly this method is for handling conversion of KeyableBean and Key for comparison.
  
  @param bean1 A value having an IType of BeanType
  @param bean2 A value having an IType of BeanType
  
  @return True if the beans are equal