Specific problems and solutions as follows:
<select id="get" resultType="xxx.domain.ReadingDO">
SELECT * FROM #{tableName} WHERE
TO_CHAR(采集时间,'yyyy-mm-dd hh24:mi:ss') = #{date};
</select>
This is very simple sql, database oracle.
first question:
First, reported first mistake: "table name is invalid" , after some agonizing, the problem is as follows, I have focused on the question mark:
* The FROM the SELECT # {} tableName the WHERE the TO_CHAR (acquisition time, 'yyyy-mm-dd hh24 : mi: ss') = # {date};
Solution: the # $ {} to {}
To sum up someone else's copy:
# {}: A parameter indicating the sql portion, the bottom actually using PreparedStatement
$ {}: Indicates string concatenation, Statement underlying objects actually used
second question:
After the first solution to the problem, followed by a second report was wrong: "Invalid relational operators" , really hurt their heads, as shown in the following problem, I have to focus on the issue marked:
* The FROM the SELECT $ {} tableName the WHERE the TO_CHAR (acquisition time, 'YYYY-mm-dd HH24: mi The: SS') = # {DATE} ;
Solution: the ";" Delete
Summary: This ";" Really I do not like, so you copy into a database query statements is completely run through, and I feel that mybaits where you can add a filter to filter out the end of the sql statement ";" after all sql write more, habitual finished a sql like to add ";."