org.hibernate.Query.setTimestamp()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(289)

本文整理了Java中org.hibernate.Query.setTimestamp方法的一些代码示例,展示了Query.setTimestamp的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setTimestamp方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setTimestamp

Query.setTimestamp介绍

[英]Bind a positional Date-valued parameter using the full Timestamp.
[中]使用完整时间戳绑定位置日期值参数。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

  1. @Test
  2. public void testTS() throws Exception {
  3. Session session = openSession();
  4. Transaction txn = session.beginTransaction();
  5. Simple sim = new Simple( Long.valueOf(1) );
  6. sim.setDate( new Date() );
  7. session.save( sim );
  8. Query q = session.createSQLQuery( "select {sim.*} from SimpleEntity {sim} where {sim}.date_ = ?" ).addEntity( "sim", Simple.class );
  9. q.setTimestamp( 0, sim.getDate() );
  10. assertTrue ( q.list().size()==1 );
  11. session.delete(sim);
  12. txn.commit();
  13. session.close();
  14. }

代码示例来源:origin: bluejoe2008/openwebflow

  1. private void setParameters(Query query, Object[] parameters)
  2. {
  3. if (parameters != null)
  4. {
  5. for (int i = 0; i < parameters.length; i++)
  6. {
  7. if (parameters[i] instanceof Date)
  8. {
  9. query.setTimestamp(i, (Date) parameters[i]);
  10. }
  11. else
  12. {
  13. query.setParameter(i, parameters[i]);
  14. }
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: stackoverflow.com

  1. java.util.Date startDate = ;
  2. java.util.Date finishDate = ;
  3. Query query = session.createQuery("from YourTable where event_date >= :startDate and event_date < :finishDate");
  4. query.setTimestamp("startDate", startDate);
  5. query.setTimestamp("finishDate", finishDate);

代码示例来源:origin: ezbz/projectx

  1. @Override
  2. public Query setTimestamp(final int position, final Date date) {
  3. return query.setTimestamp(position, date);
  4. }

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate

  1. @Override
  2. public Query setTimestamp(int i, Date date) {
  3. return query.setTimestamp(i, date);
  4. }

代码示例来源:origin: ezbz/projectx

  1. @Override
  2. public Query setTimestamp(final String name, final Date date) {
  3. return query.setTimestamp(name, date);
  4. }

代码示例来源:origin: stackoverflow.com

  1. long fetchTime = ....; /* fetch time in hours */
  2. String queryString = "FROM Orders o WHERE o.orderMade >= :orderTime";
  3. Query query = session.createQuery(queryString);
  4. Timestamp orderTime = new Timestamp(System.currentTimeMillis() - fetchTime * 60L * 60L * 1000L);
  5. query.setTimestamp("orderTime", orderTime);
  6. @SuppressWarnings("unchecked")
  7. List<Orders> orders = query.list();

代码示例来源:origin: OneBusAway/onebusaway-application-modules

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public List<Integer> doInHibernate(Session session)
  4. throws HibernateException, SQLException {
  5. Query query = session.createQuery("SELECT user.id FROM User user WHERE lastAccessTime < :lastAccessTime");
  6. query.setFirstResult(firstResult);
  7. query.setMaxResults(maxResults);
  8. query.setTimestamp("lastAccessTime", lastAccessTime);
  9. return query.list();
  10. }
  11. });

代码示例来源:origin: com.github.albfernandez/jbpm-jpdl

  1. public List findJobsWithOverdueLockTime(Date threshold) {
  2. try {
  3. return session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
  4. .setTimestamp("threshold", threshold)
  5. .list();
  6. }
  7. catch (HibernateException e) {
  8. throw new JbpmPersistenceException("could not find jobs with lock time over " + threshold,
  9. e);
  10. }
  11. }

代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl

  1. public List findJobsWithOverdueLockTime(Date threshold) {
  2. try {
  3. return session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
  4. .setTimestamp("threshold", threshold)
  5. .list();
  6. }
  7. catch (HibernateException e) {
  8. throw new JbpmPersistenceException("could not find jobs with lock time over " + threshold,
  9. e);
  10. }
  11. }

代码示例来源:origin: sakaiproject/sakai

  1. @Transactional
  2. public void purgeEvents(Date before)
  3. {
  4. getSessionFactory().getCurrentSession().getNamedQuery("purgeEventsBefore")
  5. .setTimestamp("before", before)
  6. .executeUpdate();
  7. }
  8. }

代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl

  1. public List findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
  2. try {
  3. return session.getNamedQuery("JobSession.findExclusiveJobs")
  4. .setString("lockOwner", lockOwner)
  5. .setTimestamp("now", new Date())
  6. .setParameter("processInstance", processInstance)
  7. .list();
  8. }
  9. catch (HibernateException e) {
  10. throw new JbpmPersistenceException("could not find exclusive jobs owned by '" + lockOwner
  11. + "' for " + processInstance, e);
  12. }
  13. }

代码示例来源:origin: com.github.albfernandez/jbpm-jpdl

  1. public List findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
  2. try {
  3. return session.getNamedQuery("JobSession.findExclusiveJobs")
  4. .setString("lockOwner", lockOwner)
  5. .setTimestamp("now", new Date())
  6. .setParameter("processInstance", processInstance)
  7. .list();
  8. }
  9. catch (HibernateException e) {
  10. throw new JbpmPersistenceException("could not find exclusive jobs owned by '" + lockOwner
  11. + "' for " + processInstance, e);
  12. }
  13. }

代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared

  1. @Transactional
  2. public void purgeEvents(Date before)
  3. {
  4. getSessionFactory().getCurrentSession().getNamedQuery("purgeEventsBefore")
  5. .setTimestamp("before", before)
  6. .executeUpdate();
  7. }
  8. }

代码示例来源:origin: de.the-library-code.dspace/addon-duplication-detection-service-api

  1. @Override
  2. public Iterator<Item> findByLastModifiedSince(Context context, Date since)
  3. throws SQLException
  4. {
  5. Query query = createQuery(context, "SELECT i FROM item i WHERE last_modified > :last_modified");
  6. query.setTimestamp("last_modified", since);
  7. return iterate(query);
  8. }

代码示例来源:origin: org.jbpm/pvm

  1. public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
  2. // query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.job.hbm.xml
  3. Query query = session.getNamedQuery("findExclusiveJobs");
  4. query.setTimestamp("now", Clock.getCurrentTime());
  5. query.setEntity("processInstance", processInstance);
  6. return query.list();
  7. }

代码示例来源:origin: org.ow2.bonita/bonita-pvm

  1. public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
  2. // query definition can be found at the bottom of resource
  3. // org/ow2/bonita/pvm/hibernate.job.hbm.xml
  4. Query query = session.getNamedQuery("findExclusiveJobs");
  5. query.setTimestamp("now", Clock.getCurrentTime());
  6. query.setEntity("processInstance", processInstance);
  7. return query.list();
  8. }

代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl

  1. public Date getNextUnownedDueJobDueDate(Date wakeUpDate) {
  2. try {
  3. Query query = session.getNamedQuery("JobSession.getNextUnownedDueJobDueDate")
  4. .setTimestamp("wakeUpDate", wakeUpDate);
  5. return (Timestamp) query.uniqueResult();
  6. }
  7. catch (HibernateException e) {
  8. throw new JbpmPersistenceException("could not get next job due.");
  9. }
  10. }

代码示例来源:origin: org.jbpm/pvm

  1. public JobImpl<?> findFirstAcquirableJob() {
  2. // query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.job.hbm.xml
  3. Query query = session.getNamedQuery("findFirstAcquirableJob");
  4. query.setTimestamp("now", Clock.getCurrentTime());
  5. query.setMaxResults(1);
  6. return (JobImpl<?>) query.uniqueResult();
  7. }

代码示例来源:origin: org.ow2.bonita/bonita-pvm

  1. public JobImpl<?> findFirstAcquirableJob() {
  2. // query definition can be found at the bottom of resource
  3. // org/ow2/bonita/pvm/hibernate.job.hbm.xml
  4. Query query = session.getNamedQuery("findFirstAcquirableJob");
  5. query.setTimestamp("now", Clock.getCurrentTime());
  6. query.setMaxResults(1);
  7. return (JobImpl<?>) query.uniqueResult();
  8. }

相关文章