hbwf / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

"less than" in Select annotations #787

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?
MyBatis 3.2.0, MyBatis-Spring 1.2.0

Please describe the problem.  Unit tests are best!
When I use the "less than" sign "<" in a Select annotations, I get an exception 
is thrown when initializing the application context. If I use "&lt;" it works. 
In previous MyBatis versions using "<" was working. I think it is 
counter-intuitive to be forced to use XML entities in Java code if not 
explicitly documented. 

What is the expected output? What do you see instead?
No exception :)

Can you provide stack trace, logs, error messages that are displayed?
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'mapper' defined in file 
[/media/data/Projects/EveryAware/workspaces/development/mybatis-invalid-annotati
on2/target/classes/de/fstyle/test/mybatis/invalid/annotation/mapper/Mapper.class
]: Invocation of init method failed; nested exception is 
java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: 
Could not find value method on SQL annotation.  Cause: 
org.apache.ibatis.builder.BuilderException: Error creating document instance.  
Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 38; The 
content of elements must consist of well-formed character data or markup.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at de.fstyle.test.mybatis.invalid.annotation.InvalidAnnotationTest.test(InvalidAnnotationTest.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.IllegalArgumentException: 
org.apache.ibatis.builder.BuilderException: Could not find value method on SQL 
annotation.  Cause: org.apache.ibatis.builder.BuilderException: Error creating 
document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 1; 
columnNumber: 38; The content of elements must consist of well-formed character 
data or markup.
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:98)
    at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
    ... 35 more
Caused by: org.apache.ibatis.builder.BuilderException: Could not find value 
method on SQL annotation.  Cause: org.apache.ibatis.builder.BuilderException: 
Error creating document instance.  Cause: org.xml.sax.SAXParseException; 
lineNumber: 1; columnNumber: 38; The content of elements must consist of 
well-formed character data or markup.
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.getSqlSourceFromAnnotations(MapperAnnotationBuilder.java:399)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parseStatement(MapperAnnotationBuilder.java:241)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:120)
    at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:62)
    at org.apache.ibatis.session.Configuration.addMapper(Configuration.java:628)
    at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:95)
    ... 38 more
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document 
instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 
38; The content of elements must consist of well-formed character data or 
markup.
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:253)
    at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:112)
    at org.apache.ibatis.scripting.xmltags.XMLScriptBuilder.<init>(XMLScriptBuilder.java:44)
    at org.apache.ibatis.scripting.xmltags.XMLLanguageDriver.createSqlSource(XMLLanguageDriver.java:39)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.buildSqlSourceFromStrings(MapperAnnotationBuilder.java:409)
    at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.getSqlSourceFromAnnotations(MapperAnnotationBuilder.java:392)
    ... 43 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 38; The 
content of elements must consist of well-formed character data or markup.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:391)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1404)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(XMLDocumentFragmentScannerImpl.java:2583)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2680)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:288)
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
    ... 48 more

Please provide any additional information below.
See: 
https://code.google.com/p/fstyle-test/source/browse/#git%2Fbug%2Fmybatis-invalid
-annotation

Original issue reported on code.google.com by mgb...@gmail.com on 25 Feb 2013 at 11:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 25 Feb 2013 at 3:57

GoogleCodeExporter commented 9 years ago
Should be fixed in the snapshot. Could you try it?

Original comment by eduardo.macarron on 25 Feb 2013 at 7:41

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The latest snapshot works. I downloaded MyBatis 3.2.1-SNAPSHOT from GitHub and 
ran my tests. Thanks!

Original comment by mgb...@gmail.com on 27 Feb 2013 at 9:16

GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 6 Mar 2013 at 3:12

GoogleCodeExporter commented 9 years ago
It's reproducible in release 3.2.8.

Works
@Select("<script>SELECT COUNT(*) FROM MY_TABLE WHERE ID <> #{id}</script>"

Doesn't work
@Select("<script>SELECT COUNT(*) FROM MY_TABLE WHERE ID <> #{id}</script>"

Original comment by mykhailo...@gmail.com on 26 Jan 2015 at 4:35

GoogleCodeExporter commented 9 years ago
The difference is that you are including <script> element that makes MyBatis to 
handle the String as an XML and parse and execute any dynamic element <if> 
<where> etc..

So. That is exactly the expected behaviour. 

Original comment by eduardo.macarron on 26 Jan 2015 at 8:29