I got a problem. When running this MyBatis select:
<select id="findIdByCode" resultType="long">
select USER_ID from PWD_REST_CODE
where RESTORATION_CODE = #{code}
and current_date between date_from and DATE_FROM + interval #{interval} second
</select>
I got EJB Exception:
EJB exception occurred during invocation from home or business:
com.project.auth.ejb.data.UserManagerBean_rdl8zk_Intf generated exception:
org.apache.ibatis.exceptions.PersistenceException: ### Error querying
database. Cause: java.sql.SQLSyntaxErrorException: ORA-00933: неверное
завершение SQL-предложения ### The error may exist in
com/project/auth/dao/UserDAO.xml ### The error may involve
defaultParameterMap ### The error occurred while setting parameters ### SQL:
select USER_ID from PWD_REST_CODE where RESTORATION_CODE = ? and current_date
between date_from and DATE_FROM + interval ? second ### Cause:
java.sql.SQLSyntaxErrorException: ORA-00933: неверное завершение SQL-предложения
(неверное завершение SQL-предложения stands for SQL command not properly ended)
But when I run exactly the same query in database manager:
select USER_ID from PWD_REST_CODE
where RESTORATION_CODE = '217799dfHj'
and current_date between date_from and DATE_FROM + interval '86400' second
I got the deserved id (user_id, 5). Why it happens?
interval '86400' secondis a bit different frominterval 86400 secondwhat you use in MyBasic. I suppose that because the type is NUMBER MyBatis doesn't add the quotes around it.