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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:56:33+00:00 2026-06-08T00:56:33+00:00

I have an base class Peripheral . Classes Sensor and Master are extensions of

  • 0

I have an base class Peripheral. Classes Sensor and Master are extensions of Peripheral. I need ORMlite to instantiate my Peripheral objects that were previously saved. Obviously any attempt to instantiate Peripheral reflectively will result in a ClassInstantiationException due to its abstractness. How can I have ORMlite load any Peripheral object since Peripheral is abstract?

Here is the sample of what I am doing:

@DatabaseTable(tableName="Peripheral")
abstract class Peripheral {
    @DatabaseField(generatedId="true")
    int _ID;
    @DatabaseField
    int mSerial;
}

class Sensor extends Peripheral {
}

class Master extends Peripheral {
}
  • 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-08T00:56:34+00:00Added an answer on June 8, 2026 at 12:56 am

    How can I have ORMlite load any Peripheral object since Peripheral is abstract?

    I think your problem stemmed from the fact that the @DatabaseTable needs to be on the Sensor and Master classes. It won’t hurt it to also be on the base class but it won’t be detected there.

    This will have one table named "Peripheral" used for both super-classes. Any fields (such as mSerial) from the base class will be detected and used as fields in both of the super-classes.

    The only limitation is that ORMLite is unable to differentiate between Sensor and Master. It right now is missing the feature which allows you to get all rows that are a Sensor and get all rows that are a Master. Also, it cannot generate the schema for them if the super-classes have their own fields marked with @DatabaseField.

    Edit:

    It’s important to reiterate that ORMlite (as of 3/2013) does not support multiple sub-classes in the same table. Subclasses will inherit the database fields from the base class but they have to each be in their own table. Here’s a discussion about this topic on the mailing list.

    To accomplish this, you could have 3 tables: 1 for the base class information and 2 for the sub-classes. The sub-class tables would have a foreign key to the associated base class row.

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

Sidebar

Related Questions

I have a base class that a number of other classes inherit from. The
I have a base class that inherits List<> which has multiple classes derived from
I have a base class and several concrete classes that derive from it. Lets
I have a base class with several derived classes that extend it. I want
I have simple base class with single static field. I have numerous classes that
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC
I have a base class ( car ) and a class that inherit the
I have a base class with many sub-classes, and a generic function to cache
I have a base class that looks like the following: template<typename T> class Base
I have a base class that is a Django form. The child class then

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.