Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Persist and load an Ecore model instance with an EReference of type EClass(How can I persist an Ecore model instance with an EReference of type EClass and savely load it again from the DB?)
[Teneo] Persist and load an Ecore model instance with an EReference of type EClass [message #1693500] Fri, 24 April 2015 15:05 Go to next message
Timo Rohrberg is currently offline Timo RohrbergFriend
Messages: 69
Registered: September 2011
Location: Karlsruhe
Member
Hello everybody,
Hello Martin Wink,

I am trying to persist an instance of an Ecore model which contains an EClass with an EReference of type EClass referring to either the same EClass or another one in the same Ecore model.

Without any special configuration, I get a NullPointerException deep within the Teneo framework:

java.lang.NullPointerException
	at org.eclipse.emf.teneo.hibernate.mapper.AbstractAssociationMapper.addManyToOne(AbstractAssociationMapper.java:156)
	at org.eclipse.emf.teneo.hibernate.mapper.ManyToOneMapper.process(ManyToOneMapper.java:108)
	at org.eclipse.emf.teneo.hibernate.mapper.FeatureMapper.processPAnnotatedEReference(FeatureMapper.java:194)
	at org.eclipse.emf.teneo.hibernate.mapper.FeatureMapper.process(FeatureMapper.java:110)
	at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processFeature(EntityMapper.java:651)
	at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processFeatures(EntityMapper.java:553)
	at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processEntity(EntityMapper.java:377)
	at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.processPAClass(HibernateMappingGenerator.java:238)
	at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.processPersistentClasses(HibernateMappingGenerator.java:158)
	at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.generate(HibernateMappingGenerator.java:118)
	at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.generateToString(HibernateMappingGenerator.java:129)
	at org.eclipse.emf.teneo.hibernate.HbDataStore.mapEPackages(HbDataStore.java:1075)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.mapModel(HbEntityDataStore.java:243)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.initialize(HbEntityDataStore.java:118)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.getEntityManagerFactory(HbEntityDataStore.java:333)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.createEntityManager(HbEntityDataStore.java:390)
	at de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.getEntityManager(HibernatePersistenceService.java:562)
	at de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.create(HibernatePersistenceService.java:73)
	at de.vitasystems.platform.services.persistence.hibernate.test.internal.additional.StoreEClassTest.storeAndQueryEObjectWithEClassAttribute(StoreEClassTest.java:20)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	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.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)


Searching a bit through the internet and teneo documentation, I found [1] and [2] and tried to set the @External annotation at the reference to the EClass:

    <eStructuralFeatures xsi:type="ecore:EReference" name="eClass" lowerBound="1"
        eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EClass">
      <eAnnotations source="teneo.jpa">
        <details key="appinfo" value="@External(type=&quot;org.eclipse.emf.teneo.hibernate.mapping.EcoreModelElementType&quot;)"/>
      </eAnnotations>
    </eStructuralFeatures>


At least it fails at another position then, which somehow makes sense to me as the EClass is not mapped of course:

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: EClass is not mapped [SELECT e FROM EClass AS e WHERE id = 'null']
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750)
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331)
	at org.eclipse.emf.teneo.hibernate.HbEntityDataStore$WrappedEntityManager.createQuery(HbEntityDataStore.java:570)
	at de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.loadEntityFromDB(HibernatePersistenceService.java:542)
	at de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.reassignCrossReferencedObjects(HibernatePersistenceService.java:130)
	at de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.create(HibernatePersistenceService.java:93)
	at de.vitasystems.platform.services.persistence.hibernate.test.internal.additional.StoreEClassTest.storeAndQueryEObjectWithEClassAttribute(StoreEClassTest.java:20)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	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.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: EClass is not mapped [SELECT e FROM EClass AS e WHERE id = 'null']
	at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:96)
	at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93)
	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
	at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
	at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
	at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
	... 49 more
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: EClass is not mapped
	at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:189)
	at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:109)
	at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:95)
	at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:332)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3678)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3567)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:708)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:564)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
	... 57 more


What else do I have to do to make it work? How would I map the EClass or can it be just stored as a string and on loading from the DB restored as an EClass reference?

I really appreciate your hints.

Thanks a lot and have a nice weekend.

Regards
Timo
Re: [Teneo] Persist and load an Ecore model instance with an EReference of type EClass [message #1693632 is a reply to message #1693500] Mon, 27 April 2015 07:08 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Timo,
Setting the ExternalType annotation should result in that hibernate does not try to query for EClass. So not sure if the
annotation is really being read or used. Can you check the generated hbm.xml?
(there is a getmappingxml on the datastore)

gr. Martin

On 24-04-15 17:05, Timo Rohrberg wrote:
> Hello everybody,
> Hello Martin ;),
>
> I am trying to persist an instance of an Ecore model which contains an EClass with an EReference of type EClass
> referring to either the same EClass or another one in the same Ecore model.
>
> Without any special configuration, I get a NullPointerException deep within the Teneo framework:
>
>
> java.lang.NullPointerException
> at org.eclipse.emf.teneo.hibernate.mapper.AbstractAssociationMapper.addManyToOne(AbstractAssociationMapper.java:156)
> at org.eclipse.emf.teneo.hibernate.mapper.ManyToOneMapper.process(ManyToOneMapper.java:108)
> at org.eclipse.emf.teneo.hibernate.mapper.FeatureMapper.processPAnnotatedEReference(FeatureMapper.java:194)
> at org.eclipse.emf.teneo.hibernate.mapper.FeatureMapper.process(FeatureMapper.java:110)
> at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processFeature(EntityMapper.java:651)
> at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processFeatures(EntityMapper.java:553)
> at org.eclipse.emf.teneo.hibernate.mapper.EntityMapper.processEntity(EntityMapper.java:377)
> at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.processPAClass(HibernateMappingGenerator.java:238)
> at
> org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.processPersistentClasses(HibernateMappingGenerator.java:158)
>
> at org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.generate(HibernateMappingGenerator.java:118)
> at
> org.eclipse.emf.teneo.hibernate.mapper.HibernateMappingGenerator.generateToString(HibernateMappingGenerator.java:129)
> at org.eclipse.emf.teneo.hibernate.HbDataStore.mapEPackages(HbDataStore.java:1075)
> at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.mapModel(HbEntityDataStore.java:243)
> at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.initialize(HbEntityDataStore.java:118)
> at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.getEntityManagerFactory(HbEntityDataStore.java:333)
> at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.createEntityManager(HbEntityDataStore.java:390)
> at
> de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.getEntityManager(HibernatePersistenceService.java:562)
>
> at
> de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.create(HibernatePersistenceService.java:73)
>
> at
> de.vitasystems.platform.services.persistence.hibernate.test.internal.additional.StoreEClassTest.storeAndQueryEObjectWithEClassAttribute(StoreEClassTest.java:20)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> 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.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
> at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
> at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
>
>
> Searching a bit through the internet and teneo documentation, I found [1] and [2] and tried to set the @External
> annotation at the reference to the EClass:
>
>
> <eStructuralFeatures xsi:type="ecore:EReference" name="eClass" lowerBound="1"
> eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EClass">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@External(type="org.eclipse.emf.teneo.hibernate.mapping.EcoreModelElementType")"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> At least it fails at another position then, which somehow makes sense to me as the EClass is not mapped of course:
>
>
> java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: EClass is not mapped [SELECT e
> FROM EClass AS e WHERE id = 'null']
> at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750)
> at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
> at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)
> at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331)
> at org.eclipse.emf.teneo.hibernate.HbEntityDataStore$WrappedEntityManager.createQuery(HbEntityDataStore.java:570)
> at
> de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.loadEntityFromDB(HibernatePersistenceService.java:542)
>
> at
> de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.reassignCrossReferencedObjects(HibernatePersistenceService.java:130)
>
> at
> de.vitasystems.platform.services.persistence.hibernate.internal.HibernatePersistenceService.create(HibernatePersistenceService.java:93)
>
> at
> de.vitasystems.platform.services.persistence.hibernate.test.internal.additional.StoreEClassTest.storeAndQueryEObjectWithEClassAttribute(StoreEClassTest.java:20)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> 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.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
> at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
> at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
> Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: EClass is not mapped [SELECT e FROM EClass AS e WHERE id
> = 'null']
> at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:96)
> at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)
> at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234)
> at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
> at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131)
> at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93)
> at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
> at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
> at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
> at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
> at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
> ... 49 more
> Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: EClass is not mapped
> at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:189)
> at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:109)
> at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:95)
> at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:332)
> at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3678)
> at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3567)
> at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:708)
> at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:564)
> at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
> at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
> at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278)
> at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
> ... 57 more
>
>
> What else do I have to do to make it work? How would I map the EClass or can it be just stored as a string and on
> loading from the DB restored as an EClass reference?
>
> I really appreciate your hints.
>
> Thanks a lot and have a nice weekend.
>
> Regards
> Timo


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:[EMF Store] Version for Eclipse Helios?
Next Topic:[Edapt] Create a History programmatically
Goto Forum:
  


Current Time: Wed Apr 01 10:44:30 GMT 2020

Powered by FUDForum. Page generated in 0.02117 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top