2014-01-29 71 views
3

我想爲較大的實體嵌入一個較小的類作爲字段,並且這是我在過去玩過的東西! 2.1但現在Ebean在模式創建期間給我一個錯誤。爲什麼Playframework會告訴我它不支持子類化?

這裏是我的課(非常簡單沒有任何幻想):

@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!項目已經過去了一年,所以我可能會忘記一些非常愚蠢的東西)?

回答

0

如果您使用@Entity註釋,則不必擴展Ebean的Model類

相關問題