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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:50:29+00:00 2026-06-17T23:50:29+00:00

BIG UPDATE: Ok, I see my problem is much more complicated than I thought.

  • 0

BIG UPDATE:

Ok, I see my problem is much more complicated than I thought. I have tables like this:

Patient:
id
bloodtype
level (FK to level table)
doctor (FK to doctor table)
person (FK to person table)

Doctor:
id
person (FK)
speciality
level (FK to level)

Paramedic:
id
person (FK)

Person:
id
name
surname

Account:
id
login
pass

Level:
id
account (FK)
name (one of: 'patient' , 'paramedic' , 'doctor')

In entity class I’m using now @Inheritance(strategy= InheritanceType.JOINED)
@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING,name="name")
in class Level. To check if someone is for ex. patient I have function:

public boolean ifPatient(String login) {
    account = accountfacade.getByLogin(login);
    for (Level l : account.getLevelCollection()) {
        if (l instanceof Patient) {
            return true;
        }
    }
    return false;
}

Now I have situation: I’m logged in as a doctor. I want to add a patient. I have something like this:

public Doctor findDoctor(String login) {
        account = accountfacade.getByLogin(login);
        for (Doctor d : doctorfacade.findAll()) {
            if (d.getLevel().getAccount().getLogin().equals(login)) {
                doctor = d;
                return doctor;
            }
        }
    }
@Override
    public void addPatient(Account acc, Patient pat, Person per, String login) {
    Doctor d = findDoctor(login);
    accountfacade.create(acc);
    personfacade.create(per);
    Patient p = new Patient();
    p.setAccount(acc);
    p.setBlood(pat.getBlood());
// etc
    p.setPerson(per);
    d.getPatientCollection().add(p);
    acc.getLevelCollection().add(p);
    }

But it doesn’t work. Always totally weird errors like duplicate value of primary key in table Account (but I use TableGenerator…) or NULL value in field Account but for INSERT INTO Doctor (how?! I’m creating new Patient, NOT Doctor…). I’m totally lost now, so I think most important for me now is to know if actually I can use InheritanceType.JOINED in this case.

  • 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-17T23:50:31+00:00Added an answer on June 17, 2026 at 11:50 pm

    Ok, I’ve done what I wanted. It’s not elegant, but efficient. Tables and inheritance strategy are the same. In endpoint I create account and person entities, then I create Patient entity but using EntityManager persist() method. I also need to set id of level manually ((Integer)poziomfacade.getEntityManager().createQuery("SELECT max(p.idpoziom) FROM PoziomDostepu p").getSingleResult())+1 because Generator in Level entity class doesn’t work. Nevertheless the problem is solved, thanks for every constructive comment or answer.

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

Sidebar

Related Questions

I have a big problem that a recursive treeview doesn't update any childs if
I have a big big problem. Yesterday I updated the Android SDK and, since
Update: Problem solved, and staying solved. If you want to see the site in
i would like to have a query that will solve my problem in native
I have a big problem. I want to get a list of sms and
I have encountered this problem a few times, and am not able to figure
----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was
I have a very big hadoop sequence file in the hdfs. what is the
I have a big makefile that I have configured with several phony targets. One
I have an application that loads lots of data into memory (this is because

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.