title: How to get the parent base class object super.getClass()
body: <p>I have a little problem with Java (being a C++ programmer).</p>
  
  <p>I have 2 related classes:</p>
  
  <pre><code>public class Patient() {
  ...
  }
  
  public class PatientPersistent extends Patient {
  ...
      public void foo() {
      System.out.println(super.getClass().toString());
      }
  }
  </code></pre>
  
  <p>This will output:</p>
  
  <blockquote>
    <p>class org.example.smartgwt.server.model.PatientPersistent</p>
  </blockquote>
  
  <p>Is there a way to get the parent class type? i.e.</p>
  
  <blockquote>
    <p>class org.example.smartgwt.server.model.Patient.</p>
  </blockquote>
  
  <p>This will allow me to generalize some methods which I need to implement in each child which is awful.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <h2><strong>UPDATE</strong></h2>
  
  <p>I'm using Dozer to convert my domain Hibernate object to a Serializable version. I don't want the client to know of this, so the client only sees the <strong>Patient</strong> class. On the server side I perform conversions.</p>
  
  <pre><code>public class DataObject&lt;Type&gt; {
  
      private static final Class&lt;Object&gt; DstType = Type;
  
      public Object convert(Object srcData, final BeanFactory factory) {
          Mapper mapper = (Mapper)factory.getBean("dozerMapper");
  
          return (Object)mapper.map(srcData, DstType);
      }
  }
  
  public class Patient() implements Serializable {
      public Set foo;
  }    
  
  public class PatientPersistent extends Patient {
  
      public org.hibernate.collection.PersistentSet foo;
      DataObject&lt;Patient&gt; converter = new DataObject&lt;Patient&gt;;
  
      public Patient convertToSerializable(final BeanFactory factory) {
          return (Patient)converter.convert(this, factory);
      }
  }
  
  public class main() {
      // This object is not serializable so I cannot send it to the client
      PatientPersistent serializableBar = new PatientPersistent();
  
      // Using Dozer to copy the data PatientPersistent -&gt; Patient
      // This will load the Dozer spring bean and copy as mapped
      Patient copiedSerializableData = serializableBar.convertToPersistent(bar, factory);
  }
  </code></pre>
  
  <p>I know this code does not work, but it's just to make my point. I would like to be able to <strong>convert</strong> the object to it's serializable form so that I can send it back to the client. That's why I would like to give the parent's type. Calling the <strong>mapper</strong> will always be the same thing, a source object and a Dest.class.</p>
  
  <p>Maybe I'm just too confused with java.</p>
  
  <p>Thanks</p>