I want to use the String parameter for Select Statement in MyBatis. My mapper.xml:
<select id="selectAll" parameterType="String" resultMap="fastXMLResultMap"> SELECT CREATIONDATE, DOCUMENTID, TITEL, REGTITEL, INFORCEDATE, DOCTYPE FROM #{databBaseTable} </select>
And the calling function:
public List<FastXMLObject> selectAll(String databBaseTable) { SqlSession session = sqlSessionFactory.openSession(); System.out.println("Table: "+databBaseTable); try { List<FastXMLObject> list = session.selectList("FastXMLObject.selectAll",databBaseTable); return list; } finally { session.close(); } }
The dataBaseTable line is the name of the table in my database (who would have thought) because I want to dynamically retrieve data from verified tables.
But, unfortunately, this will not work: Error: ORA-00903: Ungültiger Tabellenname (invalid table name), but it is not. When I print out the value of "databBaseTable", this is the exact name of the table. And when I write the name of the table in my mapper.xml file without a variable, it works. What am I doing wrong?
Metalhead89
source share