Note that there are some explanatory texts on larger screens.

plurals
  1. POPolymorphism with Objectify
    primarykey
    data
    text
    <p>I am trying to use Objectify with a set of classes that inherit from an abstract base class:</p> <pre><code>class Container { @Id Long id; @Embedded Set&lt;MyAbstract&gt; children = new HashSet&lt;MyAbstract&gt;(); } @Entity abstract class MyAbstract { @Id Long id; } @Subclass class Derived1 extends MyAbstract {} @Subclass class Derived2 extends MyAbstract {} </code></pre> <p>Any idea how to code for this situation? I get the following error:</p> <pre><code>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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload