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

  • Home
  • SEARCH
  • 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 8831639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:21:22+00:00 2026-06-14T08:21:22+00:00

I am trying to create a REST api using Spring MVC. Instead of writing

  • 0

I am trying to create a REST api using Spring MVC. Instead of writing CRUD methods for each of the controller, I created an abstract class that would take care of the typical REST CRUD scenarios. So I created these following classes

public interface DomainObject<ID extends Serializable> {}

public class Apps implements DomainObject<String>{}

public interface AppsRepository extends PagingAndSortingRepository<Apps, String> {}

public abstract class AbstractController<T extends PagingAndSortingRepository<DomainObject<Serializable>, Serializable>> {}

With the above class/interface definitions, how do I declare a class that extends the AbstractController?

I tried declaring AppsController using

public class AppsController extends AbstractController<AppsRepository>{}

without any luck. Eclipse is showing the following error

Bound mismatch: The type AppsRepository is not a valid substitute for the bounded parameter <T extends PagingAndSortingRepository<DomainObject<Serializable>,Serializable>> of the type AbstractController<T>

I am totally stuck. I have tried different approches for a while without any luck. Any help would be greatly appreciated.

  • 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-14T08:21:23+00:00Added an answer on June 14, 2026 at 8:21 am

    In the same way as List<String> is not a subtype of List<Object>, PagingAndSortingRepository<Apps, String> (and therefore AppsRepository) is not a subtype of PagingAndSortingRepository<DomainObject<Serializable>, Serializable>

    You could use wildcards, as it is an extension of PagingAndSortingRepository<? extends DomainObject<? extends Serializable>,? extends Serializable>> but if you do that then you’re very limited in what you can do in the AbstractController, for example you can’t have any methods that take parameters of the domain object’s ID type because you don’t know what that type is in the general case.

    You need to declare the relevant type variables in AbstractController:

    public abstract class AbstractController<IDT extends Serializable, KT extends Serializable,
        Dom extends DomainObject<IDT>, T extends PagingAndSortingRepository<Dom, KT>> {
    
      private T repository;
    
      public AbstractController(T repository) {
        this.repository = repository;
      }
    
      public Dom get(IDT objectId) {
        return repository.get(objectId);
      }
    }
    

    and make AppsController extend AbstractController<String, String, Apps, AppsRepository>.

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

Sidebar

Related Questions

Given: I'm trying to create a REST API using ASP.NET MVC . I'm using
I'm trying to create a JSON REST api using Happstack. It should allow POSTS
I'm trying to create a REST service in zend framework. I'm using zend server.
I'm trying to create a python script that logs into JIRA using their REST
I am trying to create a API based service using Symfony2 which is the
I'm trying to implement an HTML5 Amazon S3 uploader (by using the REST API),
I'm trying to create a bucket on google cloud storage using PHP and REST.
I'm trying to create a WCF client that accesses a REST API. The API
I'm using WCF REST service with API key template and trying to enforce validation
I am trying to upload a file using Node and Google Docs REST API.

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.