Example usage for org.hibernate Query setTimestamp

List of usage examples for org.hibernate Query setTimestamp

Introduction

In this page you can find the example usage for org.hibernate Query setTimestamp.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setTimestamp(String name, Date value) 

Source Link

Document

Bind the value and the time of a given Date object to a named query parameter.

Usage

From source file:com.sos.scheduler.history.db.SchedulerOrderHistoryDBLayer.java

License:Apache License

public List<SchedulerOrderHistoryDBItem> getOrderHistoryItems() {
    initSession();/*from  w  ww. j  a v  a2s  .c  o  m*/

    Query query = session.createQuery("from SchedulerOrderHistoryDBItem " + getWhere());

    if (filter.getStartTime() != null && !filter.getStartTime().equals("")) {
        query.setTimestamp("startTime", filter.getStartTime());
    }
    if (filter.getEndTime() != null && !filter.getEndTime().equals("")) {
        query.setTimestamp("endTime", filter.getEndTime());
    }
    if (filter.getOrderid() != null && !filter.getOrderid().equals("")) {
        query.setText("orderId", filter.getOrderid());
    }
    if (filter.getJobchain() != null && !filter.getJobchain().equals("")) {
        query.setText("jobChain", filter.getJobchain());
    }
    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setText("schedulerId", filter.getSchedulerId());
    }

    query.setMaxResults(filter.getLimit());

    List<SchedulerOrderHistoryDBItem> historyList = query.list();
    return historyList;
}

From source file:com.sos.scheduler.history.db.SchedulerOrderHistoryDBLayer.java

License:Apache License

public SchedulerOrderHistoryDBItem getOrderHistoryItem() {
    initSession();/*from w  w  w  .  j a  va2 s .  c  o m*/
    this.filter.setLimit(1);

    Query query = session.createQuery("from SchedulerOrderHistoryDBItem " + getWhere());

    if (filter.getSchedulerOrderHistoryId() != null) {
        query.setLong("schedulerOrderHistoryId", filter.getSchedulerOrderHistoryId());
    } else {

        if (filter.getStartTime() != null && !filter.getStartTime().equals("")) {
            query.setTimestamp("startTime", filter.getStartTime());
        }
        if (filter.getEndTime() != null && !filter.getEndTime().equals("")) {
            query.setTimestamp("endTime", filter.getEndTime());
        }
        if (filter.getOrderid() != null && !filter.getOrderid().equals("")) {
            query.setText("orderId", filter.getOrderid());
        }
        if (filter.getJobchain() != null && !filter.getJobchain().equals("")) {
            query.setText("jobChain", filter.getJobchain());
        }
        if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
            query.setText("schedulerId", filter.getSchedulerId());
        }
    }
    query.setMaxResults(filter.getLimit());

    List<SchedulerOrderHistoryDBItem> historyList = query.list();
    if (historyList.size() > 0) {
        return historyList.get(0);

    } else {
        return null;
    }
}

From source file:com.sos.scheduler.history.db.SchedulerOrderStepHistoryDBLayer.java

License:Apache License

public int deleteFromTo() {

    if (session == null) {
        beginTransaction();/*from  w w w  .j a va 2 s  . c o m*/
    }

    String hql = "delete from SchedulerOrderStepHistoryDBItem " + getWhereFromTo();

    Query query = session.createQuery(hql);
    query.setTimestamp("startTimeFrom", filter.getExecutedFrom());
    query.setTimestamp("startTimeTo", filter.getExecutedTo());

    int row = query.executeUpdate();

    return row;
}

From source file:com.sos.scheduler.history.db.SchedulerOrderStepHistoryDBLayer.java

License:Apache License

public List<SchedulerOrderStepHistoryDBItem> getSchedulerOrderStepHistoryListFromTo(int limit) {
    initSession();//from  w ww .ja  v a  2s . c o m

    Query query = session.createQuery("from SchedulerOrderStepHistoryDBItem " + getWhereFromTo()
            + filter.getOrderCriteria() + filter.getSortMode());

    if (filter.getExecutedFrom() != null && !filter.getExecutedFrom().equals("")) {
        query.setTimestamp("startTimeFrom", filter.getExecutedFrom());
    }
    if (filter.getExecutedTo() != null && !filter.getExecutedTo().equals("")) {
        query.setTimestamp("startTimeTo", filter.getExecutedTo());
    }

    if (limit > 0) {
        query.setMaxResults(limit);
    }

    List<SchedulerOrderStepHistoryDBItem> schedulerHistoryList = query.list();
    return schedulerHistoryList;

}

From source file:com.sos.scheduler.history.db.SchedulerOrderStepHistoryDBLayer.java

License:Apache License

public List<SchedulerOrderStepHistoryDBItem> getOrderStepHistoryItems(int limit) throws Exception {
    initSession();/*w  ww.jav  a  2s  .  c  om*/

    transaction = session.beginTransaction();
    Query query = session.createQuery("from SchedulerOrderStepHistoryDBItem " + getWhere());

    if (filter.getStartTime() != null && !filter.getStartTime().equals("")) {
        query.setTimestamp("startTime", filter.getStartTime());
    }
    if (filter.getEndTime() != null && !filter.getEndTime().equals("")) {
        query.setTimestamp("endTime", filter.getEndTime());
    }

    query.setMaxResults(limit);

    List<SchedulerOrderStepHistoryDBItem> historyList = query.list();
    transaction.commit();
    return historyList;
}

From source file:com.sos.scheduler.history.db.SchedulerTaskHistoryDBLayer.java

License:Apache License

@Override
public int deleteInterval() {

    if (session == null) {
        beginTransaction();//from   w w w  . j  av  a  2s.  c  o m
    }

    String hql = "delete from SchedulerTaskHistoryDBItem " + getWhereFromTo();

    Query query = session.createQuery(hql);
    if (filter.getExecutedUtcFrom() != null) {
        query.setTimestamp("startTimeFrom", filter.getExecutedUtcFrom());
    }
    if (filter.getExecutedUtcTo() != null) {
        query.setTimestamp("startTimeTo", filter.getExecutedUtcTo());
    }

    int row = query.executeUpdate();

    return row;
}

From source file:com.sos.scheduler.history.db.SchedulerTaskHistoryDBLayer.java

License:Apache License

public int delete() {

    if (session == null) {
        beginTransaction();//w w  w .  j  a  v  a  2  s .  com
    }

    String hql = "delete from SchedulerTaskHistoryDBItem " + getWhereFromTo();

    Query query = session.createQuery(hql);

    if (filter.getSchedulerId() != null && filter.getSchedulerId() != "") {
        query.setText("schedulerId", filter.getSchedulerId());
    }

    if (filter.getSeverity() != null) {
        query.setInteger("severity", filter.getSeverity().getIntValue());
    }

    if (filter.getJobname() != null && filter.getJobname() != "") {
        query.setText("jobName", filter.getJobname());
    }

    if (filter.getExecutedUtcFrom() != null) {
        query.setTimestamp("startTimeFrom", filter.getExecutedUtcFrom());
    }

    if (filter.getExecutedUtcTo() != null) {
        query.setTimestamp("startTimeTo", filter.getExecutedUtcTo());
    }

    int row = query.executeUpdate();

    return row;
}

From source file:com.sos.scheduler.history.db.SchedulerTaskHistoryDBLayer.java

License:Apache License

private List<SchedulerTaskHistoryDBItem> executeQuery(Query query, int limit) {
    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setText("schedulerId", filter.getSchedulerId());
    }/*from w  w  w.j a va  2s .  co m*/

    if (filter.getSeverity() != null) {
        query.setInteger("severity", filter.getSeverity().getIntValue());
    }

    if (filter.getJobname() != null && !filter.getJobname().equals("")) {
        query.setText("jobName", filter.getJobname());
    }

    if (filter.getExecutedUtcFrom() != null) {
        query.setTimestamp("startTimeFrom", filter.getExecutedUtcFrom());
    }
    if (filter.getExecutedUtcTo() != null) {
        query.setTimestamp("startTimeTo", filter.getExecutedUtcTo());
    }

    if (limit > 0) {
        query.setMaxResults(limit);
    }

    List<SchedulerTaskHistoryDBItem> schedulerHistoryList = query.list();
    return schedulerHistoryList;
}

From source file:com.sos.scheduler.history.db.SchedulerTaskHistoryDBLayer.java

License:Apache License

public List<SchedulerTaskHistoryDBItem> getHistoryItems() {
    int limit = this.getFilter().getLimit();
    initSession();/* w ww.ja v  a2 s .c  o m*/

    Query query = session.createQuery("from SchedulerTaskHistoryDBItem " + getWhere()
            + this.filter.getOrderCriteria() + this.filter.getSortMode());

    if (filter.getSchedulerId() != null && filter.getSchedulerId() != "") {
        query.setText("schedulerId", filter.getSchedulerId());
    }

    if (filter.getSeverity() != null) {
        query.setInteger("severity", filter.getSeverity().getIntValue());
    }

    if (filter.getJobname() != null && filter.getJobname() != "") {
        query.setText("jobName", filter.getJobname());
    }

    if (filter.getStartTime() != null) {
        query.setTimestamp("startTime", filter.getStartTime());
    }
    if (filter.getEndTime() != null && !filter.getEndTime().equals("")) {
        query.setTimestamp("endTime", filter.getEndTime());
    }

    if (limit > 0) {
        query.setMaxResults(limit);
    }

    List<SchedulerTaskHistoryDBItem> historyList = query.list();
    return historyList;

}

From source file:com.sos.scheduler.history.db.SchedulerTaskHistoryDBLayer.java

License:Apache License

public SchedulerTaskHistoryDBItem getHistoryItem() {
    this.filter.setLimit(1);
    initSession();//from  www  .  ja  v a  2 s. co  m

    Query query = session.createQuery("from SchedulerTaskHistoryDBItem " + getWhere()
            + this.filter.getOrderCriteria() + this.filter.getSortMode());

    if (filter.getSchedulerId() != null && filter.getSchedulerId() != "") {
        query.setText("schedulerId", filter.getSchedulerId());
    }

    if (filter.getSeverity() != null) {
        query.setInteger("severity", filter.getSeverity().getIntValue());
    }

    if (filter.getJobname() != null && filter.getJobname() != "") {
        query.setText("jobName", filter.getJobname());
    }

    if (filter.getStartTime() != null) {
        query.setTimestamp("startTime", filter.getStartTime());
    }
    if (filter.getEndTime() != null && !filter.getEndTime().equals("")) {
        query.setTimestamp("endTime", filter.getEndTime());
    }

    if (this.filter.getLimit() > 0) {
        query.setMaxResults(this.filter.getLimit());
    }

    List<SchedulerTaskHistoryDBItem> historyList = query.list();
    if (historyList.size() > 0) {
        return historyList.get(0);
    } else {
        return null;
    }

}