My code looks like:
Session session = sessionFactory.getCurrentSession();
Query countQuery = session.
createSQLQuery(queryString);
Long totalFilteredRecords = ((Number)countQuery.uniqueResult())
.longValue();
The queryString is:
SELECT COUNT(id)
FROM SOME_TABLE
WHERE
to_char(LAST_UPDATED_DATE, 'yyyy-mm-dd hh:mi:ss')
BETWEEN
'2015-11-13 11:40:03'
AND
'2015-11-13 11:34:03'
LAST_UPDATED_DATE is Date type.
I run this SQL on SQLDeveloper and it works well, but failed when run via Hibernate:
org.hibernate.util.JDBCExceptionReporter: SQL Error: -3407, SQLState: 22007
org.hibernate.util.JDBCExceptionReporter: data exception: invalid datetime format: yyyy-mm-dd hh:mi:ss
My database is Oracle.
Could anybody help clarify is there anything wrong?
mmis for months,mi- for minutes.LAST_UPDATED_DATEsomewhere. For example, in log table.hh24:mi:ssinstead ofhh:mi:ssLAST_UPDATED_DATEis a column with date type? So write directlyLAST_UPDATED_DATE between ... and ...