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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:05:34+00:00 2026-05-24T06:05:34+00:00

I know that you should extend Model to get all the jpa functionality. However,

  • 0

I know that you should extend Model to get all the jpa functionality. However, java does not allow multiple inheritance… Therefore, I would like to know how to architect in play the following design:

public class Person extends Model {
}

// should be able to extend Person
public class Doctor extends Model {
}

// should be able to extend Person     
public class Patient extends Model {
}

public class Item extends Model {
    // Doens't matter whether it's a Doctor or a Patient
    @ManyToMany
    public List<Person> owners;
}

Thanks in advance.

  • 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-24T06:05:34+00:00Added an answer on May 24, 2026 at 6:05 am

    Your Doctor and Patient objects should inherit from Person. Java does not allow multiple inheritance but you can extend children objects with Person which inherits model already.

    
    public class Person extends Model {
    }
    
    public class Doctor extends Person {
    }
    
    public class Patient extends Person{
    }
    
    public class Item extends Model {
        @ManyToMany
        public List owners;
    }
     

    What you cannot do in Java is:

    
    
    public class Doctor extends Person, Model {
    }
    
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We all know why Java does/should not have multiple inheritance. So this is not
I know that I should put all the html elements in body tag, but
I know that we should only create repositories for Aggregate Roots and not for
this is my first question here :) I know that I should not check
I know that c++ code should be compiled and linked by g++, not gcc.
I know that I should have schema of a table before calling NewRow method
I know that most links should be left up to the end-user to decide
I know that the following code should show and hide a tiny circular progress
I know that the reminder application should display a badge or sound or kind
I know that a command line application should return 0 on success. But are

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.