I'm currently writing a new Java project with Play Framework 2.2.2 on Ubuntu. I'm attempting to set up a very simple class hierarchy that will allow the different db-persistable elements to inherit common fields, such as id, created_at, deleted_at etc, from one common BaseEntity class to avoid having to rewrite the same boiler plate.
The example I'm working with at the moment looks like this.
@Entity
public class User extends BaseEntity {
@Id
public int id;
@Constraints.Required
public String email;
@Constraints.Required
public IUser.Status status;
public String activationCode;
public User()
{
...
}
}
To exeriment I created a simple base class with one new attribute, name. This compiled fine:
@MappedSuperclass
public abstract class BaseEntity extends Model {
protected String name;
public String getName()
{
return this.name;
}
public void setName(String value)
{
this.name = value;
}
public BaseEntity()
{
}
}
Now, when the BaseEntity class didn't contain the name field or the getset-ers, EBean could successfully save the Entity to the db. Once I added the field with the getters and setters, when trying to save the entity Play crashed with the following exception:
java.lang.NoSuchMethodError: models.User._ebean_getni_name()Ljava/lang/String; at models.User._ebean_getField(User.java:1) at com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect$Getter.get(EnhanceBeanReflect.java:162) .....
Removing the getset-ers or moving them to the base class results in the same exception. I've looked pretty tirelessly online for examples that show what I'm doing wrong, but haven't found anything that fixes it. I'm sure it's something pretty simple. Can anyone help?
Regards.