| I added a junit test that (hopefully) shows the problem when used with MySQL. I cannot test it directly at the moment because I do not have access to a MySQL database on the machine where I can work on hibernate junit tests. I will try to do it later this week. With my own project I get an exception at insert time because the insert does not quote the table name. Regarding Steves suggestion to use something like this: .. <hibernate-mapping package="org.hibernate.test.quotedidentifier"> <class name="Role" table="\\"role\""> <id column="ID" name="id" type="long"> .. It causes this exception, the xml file seems to be simple invalid this way. org.hibernate.testing.junit4.CallbackException: org.hibernate.testing.junit4.BaseCoreFunctionalTestCase#buildSessionFactory at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:203) at org.hibernate.testing.junit4.TestClassMetadata.invokeCallback(TestClassMetadata.java:187) at org.hibernate.testing.junit4.TestClassMetadata.performCallbacks(TestClassMetadata.java:181) at org.hibernate.testing.junit4.TestClassMetadata.performBeforeClassCallbacks(TestClassMetadata.java:172) at org.hibernate.testing.junit4.BeforeClassCallbackHandler.evaluate(BeforeClassCallbackHandler.java:25) at org.hibernate.testing.junit4.AfterClassCallbackHandler.evaluate(AfterClassCallbackHandler.java:25) 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.hibernate.boot.InvalidMappingException: Could not parse mapping document: org/hibernate/test/quotedidentifier/Role.hbm.xml (RESOURCE) at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:46) at org.hibernate.boot.jaxb.internal.UrlXmlSource.doBind(UrlXmlSource.java:36) at org.hibernate.boot.spi.XmlMappingBinderAccess.bind(XmlMappingBinderAccess.java:59) at org.hibernate.boot.MetadataSources.addResource(MetadataSources.java:274) at org.hibernate.cfg.Configuration.addResource(Configuration.java:498) at org.hibernate.cfg.Configuration.addResource(Configuration.java:485) at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.addMappings(BaseCoreFunctionalTestCase.java:172) at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.afterConstructAndConfigureConfiguration(BaseCoreFunctionalTestCase.java:141) at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.buildSessionFactory(BaseCoreFunctionalTestCase.java:106) 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:497) at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:200) ... 12 more Caused by: org.hibernate.boot.MappingException: Unable to perform unmarshalling at line number 0 and column 0. Message: null : origin(org/hibernate/test/quotedidentifier/Role.hbm.xml) at org.hibernate.boot.jaxb.internal.AbstractBinder.jaxb(AbstractBinder.java:174) at org.hibernate.boot.jaxb.internal.MappingBinder.doBind(MappingBinder.java:61) at org.hibernate.boot.jaxb.internal.AbstractBinder.doBind(AbstractBinder.java:102) at org.hibernate.boot.jaxb.internal.AbstractBinder.bind(AbstractBinder.java:57) at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:43) ... 25 more Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'r' (code 114) excepted space, or '>' or "/>" at [row,col {unknown-source}]: [6,31]] at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:470) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:448) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:420) at org.hibernate.boot.jaxb.internal.AbstractBinder.jaxb(AbstractBinder.java:171) ... 29 more Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'r' (code 114) excepted space, or '>' or "/>" at [row,col {unknown-source} ]: [6,31] at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:647) at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:2992) at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2959) at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2835) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069) at org.codehaus.stax2.ri.Stax2EventReaderImpl.peek(Stax2EventReaderImpl.java:367) at javax.xml.stream.util.EventReaderDelegate.peek(EventReaderDelegate.java:104) at org.hibernate.boot.jaxb.internal.stax.BufferedXMLEventReader.peek(BufferedXMLEventReader.java:96) at javax.xml.stream.util.EventReaderDelegate.peek(EventReaderDelegate.java:104) at org.hibernate.boot.jaxb.internal.stax.HbmEventReader.peek(HbmEventReader.java:47) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.handleCharacters(StAXEventConnector.java:164) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:126) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:445) ... 31 more
|