Error notes in Hibernate

Source: Internet
Author: User

1. In writing Student.hbm.xml, when the table field in the Hibernate-mapping class and database is specified, the property is accidentally written as properties, error:

ERROR:HHH000196:Error parsing XML (2): The content of element type "class" must match "(Meta*,subselect?,cache?,synchro nize*,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*, fetch-profile*,resultset*, (query|sql-query) *) ".
Exception in thread "main" org.hibernate.InvalidMappingException:Unable to read XML
At Org.hibernate.internal.util.xml.MappingReader.readMappingDocument (mappingreader.java:109)
At Org.hibernate.cfg.Configuration.add (configuration.java:490)
At Org.hibernate.cfg.Configuration.add (configuration.java:486)
At Org.hibernate.cfg.Configuration.add (configuration.java:659)
At Org.hibernate.cfg.Configuration.addResource (configuration.java:742)
At Org.hibernate.cfg.Configuration.parseMappingElement (configuration.java:2197)
At Org.hibernate.cfg.Configuration.parseSessionFactory (configuration.java:2169)
At Org.hibernate.cfg.Configuration.doConfigure (configuration.java:2149)
At Org.hibernate.cfg.Configuration.doConfigure (configuration.java:2102)
At Org.hibernate.cfg.Configuration.configure (configuration.java:2017)
At Org.hibernate.cfg.Configuration.configure (configuration.java:1996)
At Studenttest.main (studenttest.java:17)
caused by:org.xml.sax.SAXParseException:Element type "propertise" must be declared.
At Com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException (Errorhandlerwrapper.java : 195)
At Com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error (errorhandlerwrapper.java:131)
At Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (xmlerrorreporter.java:384)
At Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (xmlerrorreporter.java:318)
At Com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement (xmldtdvalidator.java:1929)
At Com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement (xmldtdvalidator.java:764)
At Com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement ( xmlnsdocumentscannerimpl.java:400)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next ( xmldocumentfragmentscannerimpl.java:2747)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next (xmldocumentscannerimpl.java:648)
At Com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next (xmlnsdocumentscannerimpl.java:140)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument ( xmldocumentfragmentscannerimpl.java:510)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (xml11configuration.java:807)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (xml11configuration.java:737)
At Com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (xmlparser.java:107)
At Com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (abstractsaxparser.java:1205)
At Com.sun.org.apache.xerces.internal.jaxp.saxparserimpl$jaxpsaxparser.parse (saxparserimpl.java:522)
At Org.dom4j.io.SAXReader.read (saxreader.java:465)
At Org.hibernate.internal.util.xml.MappingReader.readMappingDocument (mappingreader.java:78)
... One more
The reason: property is written in the properties

Property and properties are the same meaning, what is the difference between them?

The properties are used for importing external resources, followed by a path to the properties file,

2. In the Hibernate.cfg.xml file, specify the class


<mapping resource= "Com/bjsxt/hibernate/student.hbm.xml"/>

Is '/' not '. '

<mapping resource= "Com.bjsxt.hibernate/student.hbm.xml"/>

Error notes in Hibernate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.