Play Framework - How to inherit from superclass?
ebean, java, playframework, playframework-2.0
Solution
To keep the `User` table concrete, you can use the `@Inheritance` annotation. See Play Framework 2 Ebean and InheritanceType as JOINED for a discussion about that.
Also possible is to manually join auxiliar tables for Drivers and Customers using `@OneToOne`.
Using `@OneToOne` would also be favor composition over inheritance, which is considered a good practice.
Problem
I have a User class, which extends Model, and two classes that I want to extend the User class. User.java: ``` @Entity @Table(name = "users") public class User extends Model implements RoleHolder { private static final long serialVersionUID = 1L; @Id public Long id; ... ``` Driver.java: ``` public class Driver extends User { ... ``` Customer.java: ``` public class Customer extends User { ... ``` Edit All three entities need to be directly accessed. To say it another way, I have Users, Customers, and Drivers; Customers and Drivers just happen to share all of the properties of a User. Therefore, I need to have a valid User entity as well as Customer and Driver. I need to be able to get a list of all Users (including Customers and Drivers). I haven't been able to figure out how to make this work using `ebean` in Play. How can I do this?