---
title: "Create table for an abstract class in ActiveAndroid"  
description: "Create table for an abstract class in ActiveAndroid"  
author: "Anonymous User"  
published: 2015-07-09  
updated: 2015-07-09  
canonical: https://www.mindstick.com/forum/23330/create-table-for-an-abstract-class-in-activeandroid  
category: "android"  
tags: ["android", "java"]  
reading_time: 2 minutes  

---

# Create table for an abstract class in ActiveAndroid

Is it possible to create a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) for an [abstract class](https://www.mindstick.com/articles/1430/abstract-class) in ActiveAndroid. For example i could have an abstract class Animal with two concrete classes Dog and Cat. I want to be able to do something like:\

```
List<Animal> animals = new Select().from(Animals.class).execute();
```

which would [result](https://www.mindstick.com/blog/12011/advantages-of-getting-result-oriented-seo-from-an-agency) in 'animals' containing all of the saved Cats and Dogs. Or:

```
Animal animal = new Select().from(Animals.class).where("name = ?", name).executeSingle();
```

Where 'animal' could be either a Cat or a Dog. Unfortunately when I do this I get an [exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) because no table is created for the abstract class Animal. Does [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) know how I might go about this using ActiveAndroid?

## Replies

### Reply by Anonymous User

I have done some research on Internet and i found this answer :\
Unfortunately ActiveAndroid does not support inheritance of models in that way just yet ([https://github.com/pardom/ActiveAndroid/issues/14](https://github.com/pardom/ActiveAndroid/issues/14) ,[https://github.com/pardom/ActiveAndroid/issues/257](https://github.com/pardom/ActiveAndroid/issues/257)).\
If you wanted to modify ActiveAndroid here's what you could do:\
Create some kind of annotation that allows you define a model (Animals) as something that isn't persisted (refer to com.activeandroid.annotation.Table).Upon trying to executing queries for that [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) you could use reflection to determine its child classes and then have it perform that query per child class.Then you would basically take the list of results for each query and combine them into a single list and return that.To be honest I've never seen inheritance in any Android ORM libraries, and personally I don't think it's a good design pattern for models. You may want to reconsider your reasoning for going down this path.


---

Original Source: https://www.mindstick.com/forum/23330/create-table-for-an-abstract-class-in-activeandroid

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
