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.dailyschedule.db.DailyScheduleDBLayer.java

License:Apache License

public int delete() {

    if (session == null) {
        beginTransaction();//from w ww .j  ava2 s.com
    }

    String hql = "delete from DailyScheduleDBItem " + getWhere();

    Query query = session.createQuery(hql);

    if (filter.getPlannedUtcFrom() != null && !filter.getPlannedUtcFrom().equals("")) {
        query.setTimestamp("schedulePlannedFrom", filter.getPlannedUtcFrom());
    }
    if (filter.getPlannedUtcTo() != null && !filter.getPlannedUtcTo().equals("")) {
        query.setTimestamp("schedulePlannedTo", filter.getPlannedUtcTo());
    }
    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setParameter("schedulerId", filter.getSchedulerId());
    }
    int row = query.executeUpdate();

    return row;
}

From source file:com.sos.dailyschedule.db.DailyScheduleDBLayer.java

License:Apache License

public int deleteInterval() {

    if (session == null) {
        beginTransaction();/*from   w w w .j av  a2  s  . c om*/
    }

    String hql = "delete from DailyScheduleDBItem " + getWhere();

    Query query = session.createQuery(hql);

    if (filter.getPlannedUtcFrom() != null) {
        query.setTimestamp("schedulePlannedFrom", filter.getPlannedUtcFrom());
    }
    if (filter.getPlannedUtcTo() != null) {
        query.setTimestamp("schedulePlannedTo", filter.getPlannedUtcTo());
    }

    int row = query.executeUpdate();

    return row;
}

From source file:com.sos.dailyschedule.db.DailyScheduleDBLayer.java

License:Apache License

public List<DailyScheduleDBItem> getDailyScheduleList(final int limit) {
    initSession();//from www .ja v  a 2s . co m

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

    if (filter.getPlannedUtcFrom() != null && !filter.getPlannedUtcFrom().equals("")) {
        query.setTimestamp("schedulePlannedFrom", filter.getPlannedUtcFrom());
    }
    if (filter.getPlannedUtcTo() != null && !filter.getPlannedUtcTo().equals("")) {
        query.setTimestamp("schedulePlannedTo", filter.getPlannedUtcTo());
    }
    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setParameter("schedulerId", filter.getSchedulerId());
    }

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

    @SuppressWarnings("unchecked")
    List<DailyScheduleDBItem> daysScheduleList = query.list();
    return daysScheduleList;

}

From source file:com.sos.dailyschedule.db.DailyScheduleDBLayer.java

License:Apache License

private List<DailyScheduleDBItem> executeQuery(Query query, int limit) {
    if (filter.getPlannedUtcFrom() != null && !filter.getPlannedUtcFrom().equals("")) {
        query.setTimestamp("schedulePlannedFrom", filter.getPlannedUtcFrom());
    }/*from  w ww . j ava2 s  . c o  m*/
    if (filter.getPlannedUtcTo() != null && !filter.getPlannedUtcTo().equals("")) {
        query.setTimestamp("schedulePlannedTo", filter.getPlannedUtcTo());
    }
    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setParameter("schedulerId", filter.getSchedulerId());
    }

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

    List<DailyScheduleDBItem> daysScheduleList = query.list();
    return daysScheduleList;

}

From source file:com.sos.jobnet.db.JobNetCmdHistoryDBLayer.java

License:Apache License

private Query setQueryParams(String hql) {
    Query query = session.createQuery(hql);

    if (filter.getStartTimeFrom() != null && !filter.getStartTimeFrom().equals("")) {
        query.setTimestamp(START_TIME_FROM, filter.getStartTimeFrom());
    }/*w  ww  .  jav a  2 s. c  o m*/

    if (filter.getStartTimeTo() != null && !filter.getStartTimeTo().equals("")) {
        query.setTimestamp(START_TIME_TO, filter.getStartTimeTo());
    }

    if (filter.getNodeType() != null && !filter.getNodeType().equals("")) {
        query.setParameter(NODE_TYPE, filter.getNodeType());
    }

    if (filter.getUuid() != null && !filter.getUuid().equals("")) {
        query.setParameter(UUID, filter.getUuid());
    }

    if (filter.getStartOption() != null && !filter.getStartOption().equals("")) {
        query.setParameter(START_OPTION, filter.getStartOption());
    }

    if (filter.getHistoryId() != null) {
        query.setParameter(HISTORY_ID, filter.getHistoryId());
    }

    return query;
}

From source file:com.sos.jobnet.db.JobNetHistoryDBLayer.java

License:Apache License

private Query setQueryParams(String hql) {
    Query query = session.createQuery(hql);

    if (filter.getStartTimeFrom() != null && !filter.getStartTimeFrom().equals("")) {
        query.setTimestamp(START_TIME_FROM, filter.getStartTimeFrom());
    }//from   w w  w. j av  a 2 s . co  m

    if (filter.getStartTimeTo() != null && !filter.getStartTimeTo().equals("")) {
        query.setTimestamp(START_TIME_TO, filter.getStartTimeTo());
    }

    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setParameter(SCHEDULER_ID, filter.getSchedulerId());
    }

    if (filter.getUuid() != null && !filter.getUuid().equals("")) {
        query.setParameter(UUID, filter.getUuid());
    }

    if (filter.getStatus() != null && !filter.getStatus().equals("")) {
        query.setInteger(STATUS, filter.getStatus());
    }

    if (filter.getHistoryId() != null) {
        query.setParameter(HISTORY_ID, filter.getHistoryId());
    }

    if (filter.getNetId() != null) {
        query.setParameter(NET_ID, filter.getNetId());
    }

    if (filter.getExitCode() != null) {
        query.setParameter(EXIT_CODE, filter.getExitCode());
    }

    if (filter.getJobnetId() != null) {
        query.setParameter(JOBNET_ID, filter.getJobnetId());
    }

    return query;
}

From source file:com.sos.jobnet.db.JobNetPlanDBLayer.java

License:Apache License

private Query setQueryParams(String hql) {
    Query query = session.createQuery(hql);

    if (filter.getPlannedStartTimeFrom() != null && !filter.getPlannedStartTimeFrom().equals("")) {
        query.setTimestamp(PLANNED_START_TIME_FROM, filter.getPlannedStartTimeFrom());
    }/*from w w  w  .j a va  2s  .  c  o m*/

    if (filter.getPlannedStartTimeTo() != null && !filter.getPlannedStartTimeTo().equals("")) {
        query.setTimestamp(PLANNED_START_TIME_TO, filter.getPlannedStartTimeTo());
    }

    if (filter.getStartTimeFrom() != null && !filter.getStartTimeFrom().equals("")) {
        query.setTimestamp(START_TIME_FROM, filter.getStartTimeFrom());
    }

    if (filter.getStartTimeTo() != null && !filter.getStartTimeTo().equals("")) {
        query.setTimestamp(START_TIME_TO, filter.getStartTimeTo());
    }

    if (filter.getSchedulerId() != null && !filter.getSchedulerId().equals("")) {
        query.setParameter(SCHEDULER_ID, filter.getSchedulerId());
    }

    if (filter.getUuid() != null && !filter.getUuid().equals("")) {
        query.setParameter(UUID, filter.getUuid());
    }

    if (filter.getNode() != null && !filter.getNode().equals("")) {
        query.setParameter(NODE, filter.getNode());
    }

    if (filter.getNodeId() != null) {
        query.setLong(NODE_ID, filter.getNodeId());
    }

    if (filter.getSubnetId() != null) {
        query.setLong(SUBNET_ID, filter.getSubnetId());
    }

    if (filter.getConnectorId() != null) {
        query.setLong(CONNECTOR_ID, filter.getConnectorId());
    }

    if (filter.getNodeType() != null) {
        query.setParameter(NODE_TYPE, filter.getNodeType());
    }

    if (filter.getPlanId() != null) {
        query.setLong(PLAN_ID, filter.getPlanId());
    }

    if (filter.getJobnet() != null && !filter.getJobnet().equals("")) {
        query.setParameter(JOBNET, filter.getJobnet());
    }

    if (filter.getStatus() != null && !filter.getStatus().equals("")) {
        query.setInteger(STATUS, filter.getStatus());
    }

    if (filter.getStatusWaiter() != null && !filter.getStatusWaiter().equals("")) {
        query.setInteger(STATUS_WAITER, filter.getStatusWaiter());
    }

    if (filter.getStatusRunner() != null && !filter.getStatusRunner().equals("")) {
        query.setInteger(STATUS_RUNNER, filter.getStatusRunner());
    }

    if (filter.getStatusDispatcher() != null && !filter.getStatusDispatcher().equals("")) {
        query.setInteger(STATUS_DISPATCHER, filter.getStatusDispatcher());
    }

    if (filter.getIsWaiterSkipped() != null) {
        query.setBoolean(IS_WAITER_SKIPPED, filter.getIsWaiterSkipped());
    }

    if (filter.getIsRunnerOnDemand() != null) {
        query.setBoolean(IS_RUNNER_ON_DEMAND, filter.getIsRunnerOnDemand());
    }

    if (filter.getIsRunnerSkipped() != null) {
        query.setBoolean(IS_RUNNER_SKIPPED, filter.getIsRunnerSkipped());
    }

    if (filter.getBootstrap() != null) {
        query.setBoolean(BOOTSTRAP, filter.getBootstrap());
    }

    if (filter.getIsDispatcherSkipped() != null) {
        query.setBoolean(IS_DISPATCHER_SKIPPED, filter.getIsDispatcherSkipped());
    }

    return query;

}

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

License:Apache License

@Override
public int deleteInterval() {

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

    String q = "delete from SchedulerOrderStepHistoryDBItem e where e.schedulerOrderHistoryDBItem.historyId IN (select historyId from SchedulerOrderHistoryDBItem "
            + getWhereFromTo() + ")";
    Query query = session.createQuery(q);

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

    int row = query.executeUpdate();

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

    query = session.createQuery(hql);

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

    row = query.executeUpdate();

    return row;
}

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

License:Apache License

public int delete() {

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

    String q = "delete from SchedulerOrderStepHistoryDBItem e where e.schedulerOrderHistoryDBItem.historyId IN (select historyId from SchedulerOrderHistoryDBItem "
            + getWhereFromTo() + ")";
    Query query = session.createQuery(q);
    if (filter.getExecutedUtcFrom() != null) {
        query.setTimestamp("startTimeFrom", filter.getExecutedUtcFrom());
    }

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

    String hql = "delete from SchedulerOrderHistoryDBItem " + getWhereFromTo();
    query = session.createQuery(hql);
    if (filter.getExecutedUtcFrom() != null) {
        query.setTimestamp("startTimeFrom", filter.getExecutedUtcFrom());
    }
    if (filter.getExecutedUtcTo() != null) {
        query.setTimestamp("startTimeTo", filter.getExecutedUtcTo());
    }

    row = query.executeUpdate();
    return row;
}

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

License:Apache License

private List<SchedulerOrderHistoryDBItem> executeQuery(Query query, int limit) {

    if (filter.getExecutedUtcFrom() != null && !filter.getExecutedUtcFrom().equals("")) {
        query.setTimestamp("startTimeFrom", filter.getExecutedUtcFrom());
    }//from ww w  .jav a  2  s  .  c om
    if (filter.getExecutedUtcTo() != null && !filter.getExecutedUtcTo().equals("")) {
        query.setTimestamp("startTimeTo", filter.getExecutedUtcTo());
    }

    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());
    }

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

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

}