我创建了一个.hbm.xml文件:
false
这是表:
CREATE TABLE SYS.NOYS_PERSONNE ( CODE_PERS VARCHAR2(25 BYTE) NOT NULL, CODE_OBJ_PARAM_SINISTRE VARCHAR2(25 BYTE), CODE_MISSION_EXPERT VARCHAR2(25 BYTE), CODE_PROF VARCHAR2(25 BYTE), NOM_PERS VARCHAR2(100 BYTE), LOCALISATION_PERS VARCHAR2(100 BYTE), TELEPHONE_PERS VARCHAR2(100 BYTE), ADRESSE_PERS VARCHAR2(100 BYTE), TYPE_PERS VARCHAR2(5 BYTE), TITRE_PERS VARCHAR2(25 BYTE), DATE_NAISS_PERS DATE, LIEU_NAISS_PERS VARCHAR2(50 BYTE), NUM_PERMIS_PERS VARCHAR2(50 BYTE), CATEG_PERMIS_PERS VARCHAR2(50 BYTE), NUM_ID_PERS VARCHAR2(50 BYTE), DATE_ID_PERS DATE, LIEU_ID_PERS VARCHAR2(50 BYTE), CODE_UTI VARCHAR2(25 BYTE), DTE_UTI DATE, CODE_UTI_MODIF VARCHAR2(25 BYTE), DTE_UTI_MODIF DATE, ID_TRANSACTION VARCHAR2(25 BYTE), CODE_SOUS_DOSSIER VARCHAR2(25 BYTE), CODE_TYPE_BENEFICIAIRE VARCHAR2(25 BYTE), EST_TRANSIGE VARCHAR2(1 BYTE) )
以下是应用于表格的约束:
- -- Foreign Key Constraints for Table NOYS_PERSONNE -- ALTER TABLE SYS.NOYS_PERSONNE ADD ( CONSTRAINT FK_NOYS_PER_ASS29_NOYS_MIS FOREIGN KEY (CODE_MISSION_EXPERT) REFERENCES SYS.NOYS_MISSION_EXPERT (CODE_MISSION_EXPERT)); ALTER TABLE SYS.NOYS_PERSONNE ADD ( CONSTRAINT FK_NOYS_PER_TYPEPIECE_NOYPS_PA FOREIGN KEY (CODE_OBJ_PARAM_SINISTRE) REFERENCES SYS.NOYPS_PARAMSINISTRE (CODE_OBJ_PARAM_SINISTRE)); ALTER TABLE SYS.NOYS_PERSONNE ADD ( CONSTRAINT NOYS_PERSONNE_R03 FOREIGN KEY (CODE_PROF) REFERENCES OMEFIRE.NOYP_PROFESSION (CODE_PROF)); ALTER TABLE SYS.NOYS_PERSONNE ADD ( FOREIGN KEY (CODE_SOUS_DOSSIER) REFERENCES SYS.NOYS_SOUS_DOSSIER (CODE_SOUS_DOSSIER)); ALTER TABLE SYS.NOYS_PERSONNE ADD ( FOREIGN KEY (ID_TRANSACTION) REFERENCES SYS.NOYS_TRANSACTION (ID_TRANSACTION)); ALTER TABLE SYS.NOYS_ADVERSAIRE ADD ( CONSTRAINT FK_NOYS_ADV_GENERALIS_NOYS_PER FOREIGN KEY (CODE_PERS) REFERENCES SYS.NOYS_PERSONNE (CODE_PERS)); ALTER TABLE SYS.NOYS_SINISTRE_BASE ADD ( CONSTRAINT FK_NOYS_SIN_DECLARANT_NOYS_PER FOREIGN KEY (CODE_PERS) REFERENCES SYS.NOYS_PERSONNE (CODE_PERS)); ALTER TABLE SYS.NOYS_TEMOIN ADD ( CONSTRAINT FK_NOYS_TEM_GENERALIS_NOYS_PER FOREIGN KEY (CODE_PERS) REFERENCES SYS.NOYS_PERSONNE (CODE_PERS)); ALTER TABLE SYS.NOYS_DETAIL_DECOMPTE ADD ( FOREIGN KEY (CODE_PERS) REFERENCES SYS.NOYS_PERSONNE (CODE_PERS));
每当我尝试从Eclipse运行它时,我收到以下错误:
11:09:01,718 INFO [Configuration] Searching for mapping documents in jar: AfrikBrain.AssurHibernate.har 11:09:01,718 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysAssDeclPtEval.hbm.xml 11:09:01,750 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.PointsEvaluationDeclaration -> NOYS_ASS_DECL_PT_EVAL 11:09:01,765 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysCausesAnnexesSinistre.hbm.xml 11:09:01,781 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.CausesAnnexesSinistre -> NOYS_CAUSESANNEXES_SINISTRE 11:09:01,781 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysDeclarationAuto.hbm.xml 11:09:01,796 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.DeclarationAuto -> NOYS_DECLARATION_AUTO 11:09:01,796 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysDerogation.hbm.xml 11:09:01,796 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.Derogation -> NOYS_DEROGATION 11:09:01,812 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysMissionExpert.hbm.xml 11:09:01,812 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.MissionExpert -> NOYS_MISSION_EXPERT 11:09:01,812 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysMotifdero.hbm.xml 11:09:01,828 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.MotifDerogation -> NOYS_MOTIFDERO 11:09:01,828 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysMotifrefus.hbm.xml 11:09:01,843 INFO [HbmBinder] Mapping class: com.afrikbrain.iard.sinistre.hbm.dossier.Motifrefus -> NOYS_MOTIFREFUS 11:09:01,843 INFO [Configuration] Found mapping document in jar: com/afrikbrain/iard/sinistre/hbm/dossier/NoysPersonne.hbm.xml 11:09:01,843 ERROR [XMLHelper] Error parsing XML: XML InputStream(288) 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)*)". 11:09:01,859 WARN [ServiceController] Problem starting service AssurHibernate.har:service=Hibernate org.hibernate.InvalidMappingException: Could not read mapping documents from jar: AfrikBrain.AssurHibernate.har at org.hibernate.cfg.Configuration.addJar(Configuration.java:621) at org.jboss.hibernate.jmx.Hibernate.handleMappings(Hibernate.java:318) at org.jboss.hibernate.jmx.Hibernate.buildConfiguration(Hibernate.java:208) at org.jboss.hibernate.jmx.Hibernate.buildSessionFactory(Hibernate.java:228) at org.jboss.hibernate.jmx.Hibernate.startService(Hibernate.java:155) at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) 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.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978) at $Proxy0.start(Unknown Source) at org.jboss.system.ServiceController.start(ServiceController.java:417) at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy4.start(Unknown Source) at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302) at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy10.deploy(Unknown Source) at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421) at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225) Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502) at org.hibernate.cfg.Configuration.addJar(Configuration.java:618) ... 50 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.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.dom4j.io.SAXReader.read(SAXReader.java:465) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499) ... 51 more 11:09:01,875 ERROR [URLDeploymentScanner] Incomplete Deployment listing: --- MBeans waiting for other MBeans --- ObjectName: AssurHibernate.har:service=Hibernate State: FAILED Reason: org.hibernate.InvalidMappingException: Could not read mapping documents from jar: AfrikBrain.AssurHibernate.har --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: AssurHibernate.har:service=Hibernate State: FAILED Reason: org.hibernate.InvalidMappingException: Could not read mapping documents from jar: AfrikBrain.AssurHibernate.har
我的.hbm.xml文件有什么问题?
首先,XML文件的格式全部搞砸了,需要重写为:
其次,根据DTD,映射的顺序无效.您需要
向上移动元素,使其位于
元素之后,而不是靠近
元素:
false .... rest of mapping goes here ....