jrh
jrh

Reputation: 764

How to create single table though class contains nested classes?

I am new to ormlite. My requirement is to create a single table, though it contains nested classes.

class Parent {
    String name;
    int age;
    Height height;
  }

 class Height {
    int feet;
    int inch;
  }

Here, Height should not be another table, rather it should be extended columns to Parent.

is that possible ?

Thanks in advance.

Upvotes: 1

Views: 278

Answers (1)

Gray
Gray

Reputation: 116848

Here, Height should not be another table, rather it should be extended columns to Parent. Is that possible ?

It is possible however not if you also want to store Parent or other sub-classes of Parent in the same table. ORMLite does not support that pattern.

So you could have class Height extends Parent and have fields in Parent marked with @DatabaseField included in the Height table.

class Parent {
   @DatabaseField
   String name;
   ...
}
@DatabaseTable
class Height extends Parent {
   ...
}

Upvotes: 2

Related Questions