I'm creating a heirarchy of classes for the purposes of denormalizing a table. Tables are quite wide so to manage hassle and errors, I would like to declare all fields in the parent and then alter the definition of specific fields in the child. This way I can have a normal column in the parent be redefined as part of a primary key in the child.
E.g.:
Basic super-class
public class A {
@Column
protected int age;
}
Class extending A
@Table
public class B extends A {
@PrimaryKey
protected K key;
...
}
Primary key for A, with a new definition of the age
column.
@PrimaryKeyClass
public class K {
@PrimaryKeyColumn
private int age;
@PrimaryKeyColumn
private int ignore;
}
That doesn't seem to work. I get a Multiple definition of identifier
exception.
So far I can only declare fields that won't change in the parent and then declare all possibly-changing fields in each child. I don't like this because I have to know upfront every field that might become part of future primary keys.
Putting the annotations on the (parent) getters and overriding those doesn't seem to have done anything.
Any way to solve this aside from keeping only never-changing columns in the parent?