Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:07:55+00:00 2026-06-11T23:07:55+00:00

I have an abstract factory like so: public abstract class DAOFactory { public abstract

  • 0

I have an abstract factory like so:

public abstract class DAOFactory {
    public abstract EntryDAO<EntryDTO> getEntryDAO();
    ...
}

With my DAO and DTO interfaces like so:

public interface EntryDTO extends GenericDTO {
}

public interface EntryDAO<T extends EntryDTO> extends GenericDAO<T, Serializable> {  
}

And my implementation like so:

public class EntryDTOImpl implements EntryDTO {
}

public class EntryDAOImpl<T extends EntryDTO> extends GenericDaoImpl<EntryDTOImpl, ObjectId> 
 implements EntryDAO<T> {
}

Now, if I create a factory and override the getEntryDAO method like so:

public class MyDAOFactory extends DAOFactory {   
    @Override
    public EntryDAO<EntryDTO> getEntryDAO() {
        try {
            return new EntryDAOImpl<EntryDTOImpl>();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

I get a compile time error:

Type mismatch: cannot convert from EntryDAOImpl to EntryDAO

EDIT

I’ve updated my abstract factory like so:

public abstract <T extends EntryDTO> EntryDAO<T> getEntryDAO();

And made the change in my factory implementation:

@Override
public <T extends EntryDTO> EntryDAO<T> getEntryDAO() {
    try {
        return new EntryDAOImpl<EntryDTOImpl>();
    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

Now I’m getting the compile time error:

Type mismatch: cannot convert from EntryDAOImpl<EntryDTOImpl> to EntryDao<T>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:07:56+00:00Added an answer on June 11, 2026 at 11:07 pm

    Define the abstract method this way (notice ? instead of T):

    public abstract EntryDAO<? extends EntryDTO> getEntryDAO(); //should work for you
    

    I recreated the scenario the way I understood it: returning subclass1<subclass2> as interface1<interface2>

    For example, this works well:

    public static List<? extends CharSequence> dostuff1() { 
        return new ArrayList<String>();
    }
    

    But this doesn’t work:

    public <B extends CharSequence> List<B> dostuff2() {
        return new ArrayList<String>();
    }
    

    This gives the same compile-time error that you got: Type mismatch: cannot convert from ArrayList<String> to List<B>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have implemented a typical DAO/Abstract Factory pattern. The design is like this: DAOFactory
I have abstract BaseController, which basically looks like below: public abstract class BaseController :
I have some Abstract Factory public interface AbstractViewersFactory { IAbstractShapeViewer createRectangle(BaseOperationsListener<RectangleDTO> p); IAbstractShapeViewer createOval(BaseOperationsListener<OvalDTO>
In my console application have an abstract Factory class Listener which contains code for
I have a class with a factory-pattern function in it: abstract class ParentObj {
Suppose we have abstract class A (all examples in C#) public abstract class A
I have an abstract class Class. The class Subclass extends Class. The Class abstract
I have something like the following in the header class MsgBase { public: unsigned
I have an abstract class where source code looks like this: /* * @assert
I have code that looks like follows: public interface BaseDAO{ // marker interface }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.