I'm trying to understand how inheritance works in a game! But so far unsuccessfully.
So I have such a superclass:
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) abstract class SuperClass extends Model { @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_TABLE") @TableGenerator(name = "SEQ_TABLE") Long id; int testVal; }
And 2 inherited classes:
@Entity public class Sub extends SuperClass { String name; @Override public String toString() { return name; } } @Entity public class Sub1 extends SuperClass { String name; @Override public String toString() { return name; } }
Also I have 2 controllers for inherited classes:
public class Subs and Sub1s extends CRUD { }
After starting the application, I get 2 tables in MySQL db for my models (Sub and Sub1) with the following structure: id bigint (20), name varchar (255). Without testVal , which is in the superclass.
And when I try to create a new object of the Sub class in the CRUD interface, I get this error: A runtime error occurred in the template {module: crud} /app/views/tags/crud/form.html. The exception was MissingPropertyException: There is no such property: testVal for the class: models.Sub.
In {module: crud} /app/views/tags/crud/form.html (near line 64) # {crud.numberField name: field.name, value: (currentObject? CurrentObject [field.name]: null) /}
- What should I do to correctly generate MySQL tables for legacy models and fix the error?
- Is it possible to have one super controller for multiple inherited classes?
gl0om source share