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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:53:47+00:00 2026-06-18T03:53:47+00:00

I have model class: public class RecordSet { private DateRange daterange; private Master master;

  • 0

I have model class:

public class RecordSet {
    private DateRange daterange;
    private Master master;
    public DateRange getDaterange() {
        return daterange;
    }
    public void setDaterange(DateRange daterange) {
        this.daterange = daterange;
    }
    public Master getMaster() {
        return master;
    }
    public void setMaster(Master master) {
        this.master = master;
    }
}


public class DateRange {
    private Date ddate;

    public Date getDdate() {
        return ddate;
    }

    public void setDdate(Date ddate) {
        this.ddate = ddate;
    }

}

public class Master  {

    private String empcode;
    private String empname;
    private String dept;


    public String getEmpcode() {
        return empcode;
    }
    public void setEmpcode(String empcode) {
        this.empcode = empcode;
    }
    public String getEmpname() {
        return empname;
    }
    public void setEmpname(String empname) {
        this.empname = empname;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }

}

I have a statement like this

List<RecordSet> list = (List<RecordSet>) query.list();

when the above statement get’s executed I’m gettind the list Objects and Each object holds two items(Master,DateRange)?

Could any one How can I get those two model class objects

I’ve tried but facing classcast exception:

List<RecordSet> list = (List<RecordSet>) query.list();
            for(int i=0;i<list.size(); i++){
                Object set=list.get(i);
                Master masetr=(Master)set;

                System.out.println(masetr);
                }

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-06-18T03:53:48+00:00Added an answer on June 18, 2026 at 3:53 am
    You can't cast them if they are not realted .
    

    The class of the object you’re casting and the class you’re casting it to must be related by inheritance; that is, you can cast an object only to an instance of its class’s sub- or superclass-not to any random class.

    Side note: Casting downward in the class hierarchy is automatic, but casting upward is not.

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

Sidebar

Related Questions

I have my pojo classes Master: public class Master extends RecordSet{ private String empcode;
I have a Model that named word. this is my word model public class
So I have a model like this: class MyClass { public $customer = null;
I Have a model like this public partial class TableNames { public string Name
I have a object model like this public class Parent{ public int Id; public
I have model public class UploadOptionModel { public UploadOptionModel() { OutputFormat = outputFormatList.Select(i =>
In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class
I have the following model: public class Contact { public Contact() { Name =
I have the following model: public class Tag { public int Id { get;
I have a model item public class EntryInputModel { ... [Required(ErrorMessage = Description is

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.