title: Generic type polymorphism confusion?
body: <p>I have an abstract factory like so:</p>
  
  <pre><code>public abstract class DAOFactory {
      public abstract EntryDAO&lt;EntryDTO&gt; getEntryDAO();
      ...
  }
  </code></pre>
  
  <p>With my DAO and DTO interfaces like so:</p>
  
  <pre><code>public interface EntryDTO extends GenericDTO {
  }
  
  public interface EntryDAO&lt;T extends EntryDTO&gt; extends GenericDAO&lt;T, Serializable&gt; {  
  }
  </code></pre>
  
  <p>And my implementation like so:</p>
  
  <pre><code>public class EntryDTOImpl implements EntryDTO {
  }
  
  public class EntryDAOImpl&lt;T extends EntryDTO&gt; extends GenericDaoImpl&lt;EntryDTOImpl, ObjectId&gt; 
   implements EntryDAO&lt;T&gt; {
  }
  </code></pre>
  
  <p>Now, if I create a factory and override the <code>getEntryDAO</code> method like so:</p>
  
  <pre><code>public class MyDAOFactory extends DAOFactory {   
      @Override
      public EntryDAO&lt;EntryDTO&gt; getEntryDAO() {
          try {
              return new EntryDAOImpl&lt;EntryDTOImpl&gt;();
          } catch (UnknownHostException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>I get a compile time error:</p>
  
  <blockquote>
    <p>Type mismatch: cannot convert from EntryDAOImpl to EntryDAO</p>
  </blockquote>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've updated my abstract factory like so:</p>
  
  <pre><code>public abstract &lt;T extends EntryDTO&gt; EntryDAO&lt;T&gt; getEntryDAO();
  </code></pre>
  
  <p>And made the change in my factory implementation:</p>
  
  <pre><code>@Override
  public &lt;T extends EntryDTO&gt; EntryDAO&lt;T&gt; getEntryDAO() {
      try {
          return new EntryDAOImpl&lt;EntryDTOImpl&gt;();
      } catch (UnknownHostException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Now I'm getting the compile time error:</p>
  
  <blockquote>
    <p><code>Type mismatch: cannot convert from EntryDAOImpl&lt;EntryDTOImpl&gt; to EntryDao&lt;T&gt;</code></p>
  </blockquote>