Hibernate mapping help

Discussions

General J2EE: Hibernate mapping help

  1. Hibernate mapping help (1 messages)

    Hi, I am learning hibernate and getting following exception. Kindly have a look at my code, stack trace and suggest solution. mapping: Mobile.hbm.xml <!--?xml version="1.0"?--> Complete Stack Trace: org.hibernate.MappingException: Could not read mappings from resource: Mobile.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:485) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390) at org.hibernate.cfg.Configuration.configure(Configuration.java:1310) at org.hibernate.cfg.Configuration.configure(Configuration.java:1296) at com.mindtree.dao.MobileDAOImpl.addInvoice(MobileDAOImpl.java:25) at com.mindtree.dao.Test.main(Test.java:18) Caused by: org.hibernate.MappingException: invalid mapping at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:425) at org.hibernate.cfg.Configuration.addResource(Configuration.java:482) ... 8 more Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)". at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.dom4j.io.SAXReader.read(SAXReader.java:465) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422) ... 9 more Thanks
  2. Re: Hibernate mapping help[ Go to top ]

    Hello, At the very first glance, I see the hbm file is NOT adhering to the DTD. Try changing the hbm like following. Thanks & Regards Diwakar