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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:42:31+00:00 2026-05-15T22:42:31+00:00

I have a little problem with Java (being a C++ programmer). I have 2

  • 0

I have a little problem with Java (being a C++ programmer).

I have 2 related classes:

public class Patient() {
...
}

public class PatientPersistent extends Patient {
...
    public void foo() {
    System.out.println(super.getClass().toString());
    }
}

This will output:

class org.example.smartgwt.server.model.PatientPersistent

Is there a way to get the parent class type? i.e.

class org.example.smartgwt.server.model.Patient.

This will allow me to generalize some methods which I need to implement in each child which is awful.

Thanks!


UPDATE

I’m using Dozer to convert my domain Hibernate object to a Serializable version. I don’t want the client to know of this, so the client only sees the Patient class. On the server side I perform conversions.

public class DataObject<Type> {

    private static final Class<Object> DstType = Type;

    public Object convert(Object srcData, final BeanFactory factory) {
        Mapper mapper = (Mapper)factory.getBean("dozerMapper");

        return (Object)mapper.map(srcData, DstType);
    }
}

public class Patient() implements Serializable {
    public Set foo;
}    

public class PatientPersistent extends Patient {

    public org.hibernate.collection.PersistentSet foo;
    DataObject<Patient> converter = new DataObject<Patient>;

    public Patient convertToSerializable(final BeanFactory factory) {
        return (Patient)converter.convert(this, factory);
    }
}

public class main() {
    // This object is not serializable so I cannot send it to the client
    PatientPersistent serializableBar = new PatientPersistent();

    // Using Dozer to copy the data PatientPersistent -> Patient
    // This will load the Dozer spring bean and copy as mapped
    Patient copiedSerializableData = serializableBar.convertToPersistent(bar, factory);
}

I know this code does not work, but it’s just to make my point. I would like to be able to convert the object to it’s serializable form so that I can send it back to the client. That’s why I would like to give the parent’s type. Calling the mapper will always be the same thing, a source object and a Dest.class.

Maybe I’m just too confused with java.

Thanks

  • 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-15T22:42:32+00:00Added an answer on May 15, 2026 at 10:42 pm
    getClass().getSuperclass()
    

    But don’t use this. It is certainly a sign of bad design.

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

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well, since I haven't found a compelling answer to this… May 17, 2026 at 8:55 am
  • Editorial Team
    Editorial Team added an answer I'm not sure in which kernel version this was implemented,… May 17, 2026 at 8:55 am
  • Editorial Team
    Editorial Team added an answer I enabled DEBUG logging for 'org.springframework' in order to see… May 17, 2026 at 8:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a little Java problem I want to translate to Python. Therefor I
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a little problem with a Listview. I can load it with listview
I've run on a little problem today: I have a JS drop down menu
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
I’m having a little Architecture problem. In my project I have a Business Logic
I have a problem with a little .Net web application which uses the Amazon
Good day, Stackoverflow! I have a little (big) problem with porting one of my
I'm a beginner in Java programming language, and I have a problem that I
I have little knowledge of Flash but for a little Flash game I have

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.