emacarron / mybatis

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

string substitution to a select statement #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?iBatis 3.0.2

Please describe the problem.  Unit tests are best!

In old iBatis we used $variable$ for string sunstitution. Now in iBatis 3 we 
don't see any equavalent option.

select * from table $variable$ worked in iBatis 2 

I tried select * from table ${variable} and select * from table #{variable} in 
iBatis 3. Both options are not working.

What is the expected output? What do you see instead?

Expected behavior : replace variable with it's value.

what I am seeing instead: 

with "I tried select * from table ${variable}" option I am getting below 
exception

    O 
[10/6/10 15:23:16:468 PDT] 00000056 SystemErr     R 
org.apache.ibatis.exceptions.IbatisException: 
### Error querying database.  Cause: 
org.apache.ibatis.reflection.ReflectionException: There is no getter for 
property named 'orderby' in 'class java.lang.String'
### The error may exist in com/boeing/siai/pmws/mapping/PmwsSqlMap.xml
### The error may involve com.boeing.siai.pmws.domain.WorkPkgInfo.getWPIData
### The error occurred while executing a query

-----------------------------
with "I tried select * from table #{variable}" option I am getting below 
exception

[10/6/10 15:57:55:639 PDT] 00000056 SystemErr     R 
org.apache.ibatis.exceptions.IbatisException: 
### Error querying database.  Cause: java.sql.SQLException: ORA-00920: invalid 
relational operator

### The error may involve 
com.boeing.siai.pmws.domain.WorkPkgInfo.getWPIData-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLException: ORA-00920: invalid relational operator

Please provide any additional information below.

Original issue reported on code.google.com by rmasa...@gmail.com on 6 Oct 2010 at 11:17

GoogleCodeExporter commented 9 years ago
I use ${var} all the time, and it works fine.

Original comment by posth...@gmail.com on 7 Oct 2010 at 2:15

GoogleCodeExporter commented 9 years ago
It is working now.

I replaced ${variable}"  with ${value}

and I am calling session.clearCatch() method before session.select() to clear 
the catch.

Original comment by rmasa...@gmail.com on 8 Oct 2010 at 7:24

GoogleCodeExporter commented 9 years ago
Although this works, it's not very well documented.  Could someone mention 
${value} in the section on string substitution on page 28 of the user guide?

Original comment by mpass...@grovehillsoftware.com on 20 Oct 2010 at 3:06

GoogleCodeExporter commented 9 years ago
This feature is documented on page 28 of the current 3.0.2 User Guide

Original comment by nathan.m...@gmail.com on 2 Nov 2010 at 2:28

GoogleCodeExporter commented 9 years ago
Nathan, I see that you recently uploaded a new copy of the user guide.  Is it 
possible that you uploaded the wrong one?  I looked on page 28 and searched for 
"${value}" and "$value" and was unable to find any reference to it.

Original comment by mpass...@grovehillsoftware.com on 2 Nov 2010 at 3:06