为什么Playframework告诉我它不支持子类化?

时间:2014-01-29 00:31:50

标签: java playframework ebean

我正在尝试将一个较小的类作为字段嵌入到一个更大的实体中,这是我过去使用的游戏! 2.1但是现在Ebean在架构创建过程中给了我一个错误。

这是我的课(非常简单没什么特别的):

@Embeddable
public class Pricing implements Serializable {

    private Long value;

    private String currency;

    //getters and setters
}

我试图像这样嵌入它:

@Entity
public class MyEntity extends Model {

    @Id
    @GeneratedValue
    private Long id;

    @Embedded
    private Pricing priceProposed;

    //getters and setters
}

我想要实现的是一个看起来像这样的表

----------------------------------------------------
| id | priceProposed.value | priceProposed.currency|
----------------------------------------------------
| 1  | 200                 | USD                   |
| 2  | 1200000             | JPY                   |
----------------------------------------------------

就像你看到我没有尝试任何困难。但我收到以下错误,提到不再支持子类化。但我不相信这个资格为subClassing,或者我完全错了?

javax.persistence.PersistenceException: Entity type class models.product.Pricing is not an enhanced entity bean. Subclassing is not longer supported in Ebean
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.checkSubclass(BeanDescriptorManager.java:1482)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(BeanDescriptorManager.java:1433)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1150)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1070)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createEmbedded(BeanDescriptorManager.java:475)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEmbeddedDeployment(BeanDescriptorManager.java:498)
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:234)
    at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:114)
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:204)
    at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:65)
    at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:58)
    at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:79)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
    at play.api.Play$.start(Play.scala:87)
    at play.api.Play.start(Play.scala)
    at play.test.Helpers.start(Helpers.java:359)
    at framework.AbstractPlayApplicationTest.setup(AbstractPlayApplicationTest.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

有人能告诉我发生了什么事吗?这有什么关系?有人看到某些东西我做错了(自从我上一次Ebean + Play!项目开始已经有一年了,所以我可能会忘记一些非常愚蠢的东西)?

1 个答案:

答案 0 :(得分:0)

如果使用@Entity批注

,则不必扩展Ebean的Model类