- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 Objectify 与一组从抽象基类继承的类一起使用:
class Container {
@Id Long id;
@Embedded Set<MyAbstract> children = new HashSet<MyAbstract>();
}
@Entity
abstract class MyAbstract {
@Id Long id;
}
@Subclass class Derived1 extends MyAbstract {}
@Subclass class Derived2 extends MyAbstract {}
java.lang.RuntimeException: java.lang.InstantiationException
at com.googlecode.objectify.impl.TypeUtils.newInstance(TypeUtils.java:321)
at com.googlecode.objectify.impl.load.EmbeddedMultivalueSetter.safeSet(EmbeddedMultivalueSetter.java:89)
at com.googlecode.objectify.impl.load.CollisionDetectingSetter.set(CollisionDetectingSetter.java:37)
at com.googlecode.objectify.impl.Transmog.load(Transmog.java:326)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.toObject(ConcreteEntityMetadata.java:212)
at com.googlecode.objectify.impl.QueryImpl$ToObjectIterator.translate(QueryImpl.java:611)
at com.googlecode.objectify.impl.QueryImpl$ToObjectIterator.translate(QueryImpl.java:1)
at com.googlecode.objectify.util.TranslatingIterator.next(TranslatingIterator.java:35)
at com.googlecode.objectify.impl.QueryImpl.get(QueryImpl.java:368)
at com.foodblox.server.model.ObjectifyTest.creation(ObjectifyTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.googlecode.objectify.impl.TypeUtils.newInstance(TypeUtils.java:319)
... 33 more
最佳答案
[编辑:此答案已过时。多态适用于 Objectify v5+ 中的嵌入式类]
Objectify 提供的多态性(从 3.0beta2 开始)允许您以与 JPA 类似(但不完全相同)的方式创建多态实体。但是,与 JPA 一样,这种多态性不会扩展到 @Embedded 类。
请求此行为并非完全不合理 - 在问题跟踪器中提交功能请求。
关于java - Objectify 的多态性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5278717/
我正在像这样使用 Objectify 保存一个对象: Thing th = new Thing(); th.identifier = thingId; th.name = thingName; th.
我正在像这样使用 Objectify 保存一个对象: Thing th = new Thing(); th.identifier = thingId; th.name = thingName; th.
是否可以通过仅返回特定列表字段为空的实体来过滤 objectify 中的实体? 例如,如果我有一个客户端实体,它有一个属性“地址”,属于列表类型,我如何才能只返回根本没有关联地址的客户端? 是否有某种
我正在使用 Google App engine1.9.3、Eclipse、Objectify5.03。我的类(class)如下: import com.googlecode.objectify.Ref
我从 http://code.google.com/p/objectify-appengine/downloads/list 下载了 Objectify 3.1 库,当我遵循指南时,他们说我应该用 @
我已经阅读了一些文档,但还无法与数据存储区进行通信……谁能给我一个在 GWT Web 应用程序中使用的 objectify 的示例项目/代码(我使用 eclipse)……只是一个简单的“使用 RPC
我正在尝试将 Objectify 与一组从抽象基类继承的类一起使用: class Container { @Id Long id; @Embedded Set children = new H
我正在使用 Ojectify 来存储数据存储区,我有一个实体,当我保存更改时保留它,但在浏览器中显示它有时会显示以前的数据,有时会显示新数据。 @Entity public class BrandDt
此查询有效,fullPath字段是 List : KeyLookup lookup = ofy().load().type(KeyLookup.class).filter("f
作为 Google Cloud Datastore 的新手,我想确保自己走在正确的道路上。 我需要什么: 多对多关系 关系本身必须保存描述关系的数据 两种方式都需要强一致性: 从用户实体到该用户有权访
考虑更复杂的实体结构,例如 class Entity { Float valueA; Float valueB; List properties; } class Proper
我在 Google App Engine 上使用 Objectify 5.1.1。我定义了一个名为 Insight 的 Objectify 实体,并尝试通过名为 Downloaded 的 boolea
我有三个实体:人类、狗、零食。 Treat 实体拥有 key Key ,并且 Dog 实体拥有 key Key 。当我查询 Treat 时,我想要一个包含 Dog 的实际实体的响应,并且 Dog 的实
sample Objectify code显示以默认可见性声明的实体字段,例如, public class Car { @Id Long id; String vin; int
我需要获取 datePublished IS NOT "" 的项目列表。但是,下面的代码不起作用。有任何想法吗?谢谢 Query q=ofy.query(Diagram.class).filter("
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我正在尝试有效地获取给定父实体的所有子实体。现在唯一的方法是在 objectify 中使用查询,但效率不高,因为它绕过了缓存。 Objectify-4 添加了混合查询,您可以在 Objectify 3
我正在尝试使用谷歌云端点和对象化找到一些具体示例。我已经找到了一些具有端点或对象化的,但没有一个将它们结合在一起。 最佳答案 当我开始学习 objectify 和 endpoints 时遇到了和你一样
当应用程序存储两种实体时: com.mycompany.kind.Model 和 com.mycompany.otherkind.Model 这将如何以相同类型的“模型”存储在数据存储集合中?或者不是
我想执行一个查询,获取结果,然后将光标移至下一项(如果有)。我发现的唯一相关帖子是:Objectify paging with Cursors 有没有一种方法可以在不迭代项目的情况下执行此操作? Qu
我是一名优秀的程序员,十分优秀!