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 6651933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:04:14+00:00 2026-05-26T01:04:14+00:00

currently I’m trying to implement a typed generic DAO . I do not even

  • 0

currently I’m trying to implement a typed generic DAO.

I do not even get to compile anything, since NetBeans complains about UserDAOHibernate

interface expected here
type argument User is not within bounds of type-variable ENTITY

I’m afraid there is some obvious mistake in how I use inheritance/interfaces, since I’m rather new to Java.

Here’s some stripped down code

public interface GenericEntity<ID extends Serializable> {
    public abstract ID getId();
    public abstract void setId(final ID id);
}

public abstract class LongEntity implements GenericEntity<Long> {
    protected Long id;
    public Long getId();
    public void setId(final Long id);
}

public class User extends LongEntity implements Serializable {
    private String name;
    private String password;
    private Customer customer;
}

public interface GenericDAO<ENTITY extends GenericEntity<ID>, ID extends Serializable> {
    public abstract ENTITY findById(ID id);
    public abstract List<ENTITY> findAll();
    public abstract ENTITY makePersistent(ENTITY entity);
    public abstract void makeTransient(ENTITY entity);
}

public abstract class GenericHibernateDAO<ENTITY extends GenericEntity<ID>, ID extends Serializable>
        implements GenericDAO<ENTITY, ID> {
}

public class UserDAOHibernate implements GenericHibernateDAO<User, LongEntity> {
}

Is it that LongEntity should extend GenericEntity<Long>? If so, how would I do this with Java’s single level or inheritance?

Is this layered approach a bad example to follow? All my entities need an id and this implementation could easily be reused lateron with different id types, so I thought I might use it.

  • 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-05-26T01:04:14+00:00Added an answer on May 26, 2026 at 1:04 am

    The error comes from here:

    public class UserDAOHibernate implements GenericHibernateDAO<User, LongEntity> {
    }
    

    You’ve specified that GenericHibernateDAO‘s ID parameterized type is bounded by <ID extends Serializable>.

    LongEntity extends GenericEntity, and hence, why you have a type mismatch.

    Also, GenericHibernateDAO is an abstract class (and not an interface), so you’ll need to extends instead of implements.

    The correct solution should be:

    public class UserDAOHibernate extends GenericHibernateDAO<User, Long> {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I’m trying to get the hang of a block copy with my current
Currently I'm trying to parse some html and return an array with the values
Currently It just opens up the xml, but i want to get a dialog
Currently I'm learning C++ and I've been trying to create a simple image processing
Currently, db4o does not allow indexing on the contents of collections. What object databases
Currently unable to get my rss feed to validate through W3C RSS Validator .
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently my workflow with Emacs when I am coding in C or C++ involves
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches

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.