本文整理了Java中org.hibernate.Query.setTimestamp
方法的一些代码示例,展示了Query.setTimestamp
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setTimestamp
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setTimestamp
[英]Bind a positional Date-valued parameter using the full Timestamp.
[中]使用完整时间戳绑定位置日期值参数。
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testTS() throws Exception {
Session session = openSession();
Transaction txn = session.beginTransaction();
Simple sim = new Simple( Long.valueOf(1) );
sim.setDate( new Date() );
session.save( sim );
Query q = session.createSQLQuery( "select {sim.*} from SimpleEntity {sim} where {sim}.date_ = ?" ).addEntity( "sim", Simple.class );
q.setTimestamp( 0, sim.getDate() );
assertTrue ( q.list().size()==1 );
session.delete(sim);
txn.commit();
session.close();
}
代码示例来源:origin: bluejoe2008/openwebflow
private void setParameters(Query query, Object[] parameters)
{
if (parameters != null)
{
for (int i = 0; i < parameters.length; i++)
{
if (parameters[i] instanceof Date)
{
query.setTimestamp(i, (Date) parameters[i]);
}
else
{
query.setParameter(i, parameters[i]);
}
}
}
}
}
代码示例来源:origin: stackoverflow.com
java.util.Date startDate = … ;
java.util.Date finishDate = … ;
Query query = session.createQuery("from YourTable where event_date >= :startDate and event_date < :finishDate");
query.setTimestamp("startDate", startDate);
query.setTimestamp("finishDate", finishDate);
代码示例来源:origin: ezbz/projectx
@Override
public Query setTimestamp(final int position, final Date date) {
return query.setTimestamp(position, date);
}
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public Query setTimestamp(int i, Date date) {
return query.setTimestamp(i, date);
}
代码示例来源:origin: ezbz/projectx
@Override
public Query setTimestamp(final String name, final Date date) {
return query.setTimestamp(name, date);
}
代码示例来源:origin: stackoverflow.com
long fetchTime = ....; /* fetch time in hours */
String queryString = "FROM Orders o WHERE o.orderMade >= :orderTime";
Query query = session.createQuery(queryString);
Timestamp orderTime = new Timestamp(System.currentTimeMillis() - fetchTime * 60L * 60L * 1000L);
query.setTimestamp("orderTime", orderTime);
@SuppressWarnings("unchecked")
List<Orders> orders = query.list();
代码示例来源:origin: OneBusAway/onebusaway-application-modules
@SuppressWarnings("unchecked")
@Override
public List<Integer> doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery("SELECT user.id FROM User user WHERE lastAccessTime < :lastAccessTime");
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
query.setTimestamp("lastAccessTime", lastAccessTime);
return query.list();
}
});
代码示例来源:origin: com.github.albfernandez/jbpm-jpdl
public List findJobsWithOverdueLockTime(Date threshold) {
try {
return session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
.setTimestamp("threshold", threshold)
.list();
}
catch (HibernateException e) {
throw new JbpmPersistenceException("could not find jobs with lock time over " + threshold,
e);
}
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
public List findJobsWithOverdueLockTime(Date threshold) {
try {
return session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
.setTimestamp("threshold", threshold)
.list();
}
catch (HibernateException e) {
throw new JbpmPersistenceException("could not find jobs with lock time over " + threshold,
e);
}
}
代码示例来源:origin: sakaiproject/sakai
@Transactional
public void purgeEvents(Date before)
{
getSessionFactory().getCurrentSession().getNamedQuery("purgeEventsBefore")
.setTimestamp("before", before)
.executeUpdate();
}
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
public List findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
try {
return session.getNamedQuery("JobSession.findExclusiveJobs")
.setString("lockOwner", lockOwner)
.setTimestamp("now", new Date())
.setParameter("processInstance", processInstance)
.list();
}
catch (HibernateException e) {
throw new JbpmPersistenceException("could not find exclusive jobs owned by '" + lockOwner
+ "' for " + processInstance, e);
}
}
代码示例来源:origin: com.github.albfernandez/jbpm-jpdl
public List findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
try {
return session.getNamedQuery("JobSession.findExclusiveJobs")
.setString("lockOwner", lockOwner)
.setTimestamp("now", new Date())
.setParameter("processInstance", processInstance)
.list();
}
catch (HibernateException e) {
throw new JbpmPersistenceException("could not find exclusive jobs owned by '" + lockOwner
+ "' for " + processInstance, e);
}
}
代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared
@Transactional
public void purgeEvents(Date before)
{
getSessionFactory().getCurrentSession().getNamedQuery("purgeEventsBefore")
.setTimestamp("before", before)
.executeUpdate();
}
}
代码示例来源:origin: de.the-library-code.dspace/addon-duplication-detection-service-api
@Override
public Iterator<Item> findByLastModifiedSince(Context context, Date since)
throws SQLException
{
Query query = createQuery(context, "SELECT i FROM item i WHERE last_modified > :last_modified");
query.setTimestamp("last_modified", since);
return iterate(query);
}
代码示例来源:origin: org.jbpm/pvm
public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
// query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.job.hbm.xml
Query query = session.getNamedQuery("findExclusiveJobs");
query.setTimestamp("now", Clock.getCurrentTime());
query.setEntity("processInstance", processInstance);
return query.list();
}
代码示例来源:origin: org.ow2.bonita/bonita-pvm
public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
// query definition can be found at the bottom of resource
// org/ow2/bonita/pvm/hibernate.job.hbm.xml
Query query = session.getNamedQuery("findExclusiveJobs");
query.setTimestamp("now", Clock.getCurrentTime());
query.setEntity("processInstance", processInstance);
return query.list();
}
代码示例来源:origin: org.jbpm.jbpm3/jbpm-jpdl
public Date getNextUnownedDueJobDueDate(Date wakeUpDate) {
try {
Query query = session.getNamedQuery("JobSession.getNextUnownedDueJobDueDate")
.setTimestamp("wakeUpDate", wakeUpDate);
return (Timestamp) query.uniqueResult();
}
catch (HibernateException e) {
throw new JbpmPersistenceException("could not get next job due.");
}
}
代码示例来源:origin: org.jbpm/pvm
public JobImpl<?> findFirstAcquirableJob() {
// query definition can be found at the bottom of resource org/jbpm/pvm/hibernate.job.hbm.xml
Query query = session.getNamedQuery("findFirstAcquirableJob");
query.setTimestamp("now", Clock.getCurrentTime());
query.setMaxResults(1);
return (JobImpl<?>) query.uniqueResult();
}
代码示例来源:origin: org.ow2.bonita/bonita-pvm
public JobImpl<?> findFirstAcquirableJob() {
// query definition can be found at the bottom of resource
// org/ow2/bonita/pvm/hibernate.job.hbm.xml
Query query = session.getNamedQuery("findFirstAcquirableJob");
query.setTimestamp("now", Clock.getCurrentTime());
query.setMaxResults(1);
return (JobImpl<?>) query.uniqueResult();
}
内容来源于网络,如有侵权,请联系作者删除!