Just out of curiosity, what is the best way to accomplish this using hibernate
select *
from USERS
where TO_CHAR(CREATE_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.FF') = '1972- 07-31 13:52:50.381000'
Just out of curiosity, what is the best way to accomplish this using hibernate
select *
from USERS
where TO_CHAR(CREATE_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.FF') = '1972- 07-31 13:52:50.381000'
Date date = dateFormat.parse("1972-07-31 13:52:50.381");
String hql = "select u from User u where u.createTimestamp = :timestamp";
return session.createQuery(hql).setTimestamp("timestamp", date).list();
我正在使用标准 api:发布后,我让它按如下方式工作:
Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(User.class);
criteria.add(Restrictions.sqlRestriction("TO_CHAR(CREATE_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.FF')='1972-07-31 13:52:50.381000'"));