Ebean inheritance "Abstract class with no readMethod" exception
I try to use inheritance with Ebean in Play! Framework 2.1.0. The
inheritance strategy is "single table", as it is the only one supported by
Ebean. I closely follow example from JPA Wikibook
@Entity
@Inheritance
@DiscriminatorColumn(name="price_type")
@Table(name="prices")
public abstract class Price {
@Id
public long id;
// Price value
@Column(precision=2, scale=18)
public BigDecimal value;
}
@Entity
@DiscriminatorValue("F")
public class FixedPrice extends Price {
// NO id field here
...
}
@Entity
@DiscriminatorValue("V")
public class VariablePrice extends Price {
// NO id field here
...
}
This code passes compilation, but I get
RuntimeException: Abstract class with no readMethod for models.Price.id
com.avaje.ebeaninternal.server.deploy.ReflectGetter.create(ReflectGetter.java:33)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setBeanReflect(BeanDescriptorManager.java:1353)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1142)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1058)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:252)
com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:124)
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:210)
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)
com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:59)
play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:79)
Google search brings only one relevant link which is source code of
ReflectGetter.java. The comment there says
For abstract classes that hold the id property we need to use reflection
to get the id values some times.
This provides the BeanReflectGetter objects to do that.
If I drop abstract keyword from superclass declaration, exception
disappears. I would really prefer not to make superclass concrete though.
No comments:
Post a Comment