Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] @Embedded tag results in parse error on Hibernate mapping file(Using the @Embedded tag appears to result in an invalid Hibernate mapping file?)
[Teneo] @Embedded tag results in parse error on Hibernate mapping file [message #1778913] Sat, 23 December 2017 17:40
Daniel Tuohy is currently offline Daniel TuohyFriend
Messages: 1
Registered: December 2017
Junior Member
Hello,

I am attempting to use the @Embeddable and at @Embedded JPA tags to embed a simple component class in the parent. I am seeing an error whether I use the TABLE_PER_CLASS or JOINED mapping strategy. I am using Teneo 2.1.0, Hibernate 4.3.7 and EMF 2.12.0

I have created a minimal example with the following ecore:

  <eSubpackages name="core" 
      nsPrefix="core">
    <eClassifiers xsi:type="ecore:EClass" name="A_IDedEntity" abstract="true">
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
          iD="true"/>
    </eClassifiers>
    <eClassifiers xsi:type="ecore:EClass" name="BoundedDouble" instanceTypeName="BoundedDouble"
        eSuperTypes="#//core/A_IDedEntity">
      <eAnnotations source="teneo.jpa">
        <details key="value" value="@Embeddable"/>
      </eAnnotations>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" lowerBound="1"
          eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="minValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/>
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="maxValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/>
    </eClassifiers>
    <eClassifiers xsi:type="ecore:EClass" name="Airplane" eSuperTypes="#//core/A_IDedEntity">
      <eStructuralFeatures xsi:type="ecore:EReference" name="range" lowerBound="1"
          eType="#//core/BoundedDouble" containment="true" resolveProxies="false">
        <eAnnotations source="teneo.jpa">
          <details key="value" value="@Embedded"/>
        </eAnnotations>
      </eStructuralFeatures>
    </eClassifiers>
  </eSubpackages>


This results in the following HBM mapping file:

<hibernate-mapping auto-import="false">
	<class name="emf.com.stottlerhenke.carts.model.core.impl.A_IDedEntityImpl" entity-name="A_IDedEntity" abstract="true" lazy="false" table="`a_idedentity`">
		<meta attribute="eclassName" inherit="false">A_IDedEntity</meta>
		<id name="id" type="java.lang.String">
			<column not-null="true" unique="false" name="`id`"/>
		</id>
	</class>
	<union-subclass name="emf.com.stottlerhenke.carts.model.core.impl.AirplaneImpl" entity-name="Airplane" abstract="false" lazy="false" extends="A_IDedEntity" table="`airplane`">
		<meta attribute="eclassName" inherit="false">Airplane</meta>
		<component name="range" class="emf.com.stottlerhenke.carts.model.core.impl.BoundedDoubleImpl">
			<id name="id" type="java.lang.String">
				<column not-null="true" unique="false" name="`range_id`"/>
			</id>
			<meta attribute="eclassName" inherit="false">BoundedDouble</meta>
			<property name="value" lazy="false" insert="true" update="true" not-null="true" unique="false" type="double">
				<column not-null="true" unique="false" name="`range_value`"/>
			</property>
			<property name="minValue" lazy="false" insert="true" update="true" not-null="false" unique="false" type="double">
				<column not-null="false" unique="false" name="`range_minvalue`"/>
			</property>
			<property name="maxValue" lazy="false" insert="true" update="true" not-null="false" unique="false" type="double">
				<column not-null="false" unique="false" name="`range_maxvalue`"/>
			</property>
		</component>
	</union-subclass>
</hibernate-mapping>


And then the following parse exception on that file:

org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:375)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:304)
at org.hibernate.cfg.Configuration.add(Configuration.java:518)
at org.hibernate.cfg.Configuration.add(Configuration.java:514)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:659)
at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.mapModel(HbSessionDataStore.java:259)
at org.eclipse.emf.teneo.hibernate.HbSessionDataStore.initialize(HbSessionDataStore.java:108)
at arch.com.stottlerhenke.carts.api.database.CartsDatabaseImpl.initializeHibernateStore(CartsDatabaseImpl.java:185)
at arch.com.stottlerhenke.carts.api.database.CartsDatabaseImpl.initialize(CartsDatabaseImpl.java:98)
at arch.com.stottlerhenke.carts.api.database.CartsDatabaseImpl.getInstance(CartsDatabaseImpl.java:110)
at arch.com.stottlerhenke.carts.api.crud.CartsCrudImpl.addObjectToContainerSaveAndPrepareResponse(CartsCrudImpl.java:566)
at arch.com.stottlerhenke.carts.api.crud.CartsCrudImpl.createNewObjects(CartsCrudImpl.java:561)
at com.stottlerhenke.carts.regression.CartsCrudTestingImpl.createNewObjects(CartsCrudTestingImpl.java:38)
at arch.com.stottlerhenke.carts.api.crud.A_CartsCrudImpl.createNewObject(A_CartsCrudImpl.java:32)
at com.stottlerhenke.carts.regression.DataModelCRUDTests.createMinimalAirplane(DataModelCRUDTests.java:39)
at com.stottlerhenke.carts.regression.DataModelCRUDTests.createAirplane(DataModelCRUDTests.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
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.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
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:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 15; The content of element type "component" must match "(meta*,tuplizer*,parent?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|array|primitive-array)*)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:325)
... 40 more

Any ideas what might be happening?

Thanks,

Daniel
Previous Topic:How to improve generated editor?
Next Topic:Reloading the resources into the application
Goto Forum:
  


Current Time: Sat Sep 22 09:50:08 GMT 2018

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

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

Back to the top