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.knowbout.epg.entities.Schedule.java

License:Apache License

/**
 */// ww  w  .  j a  v  a 2  s.  c  o m
public static NetworkSchedule selectByTimeAndNetwork(String lineup, Date date, long networkId) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getNowPlaying");
    query.setTimestamp("currentTime", date);
    query.setLong("network", networkId);
    query.setString("lineup", lineup);
    NetworkSchedule sked = (NetworkSchedule) query.uniqueResult();
    return sked;
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

/**
 *//*from  w  w w .j a v a2  s.  co m*/
public static NetworkSchedule selectByTimeAndNetwork(String lineup, Date date, String callSign) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getNowPlayingCallSign");
    query.setTimestamp("currentTime", date);
    query.setString("callSign", callSign);
    query.setString("lineup", lineup);
    NetworkSchedule sked = (NetworkSchedule) query.uniqueResult();
    return sked;
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

/**
 *///from   w  w w  .j a v a2 s . c  o  m
@SuppressWarnings("unchecked")
public static List<NetworkSchedule> selectByTime(String lineup, Date date) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getNowPlayingLineup");
    query.setTimestamp("currentTime", date);
    query.setString("lineup", lineup);
    return (List<NetworkSchedule>) query.uniqueResult();
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

private static Query createNextAiringsQuery(String lineup, String where, boolean onlyIfNew,
        boolean includeNowAiring, int limit) {
    StringBuilder q = new StringBuilder();
    q.append("from NetworkSchedule as n ");
    q.append(where);/* ww w .j  a  v a2 s. c o m*/
    q.append(" and n.networkLineup.id = :lineup");
    if (includeNowAiring) {
        q.append(" and n.schedule.endTime > :currentTime");
    } else {
        q.append(" and n.schedule.airTime > :currentTime");
    }
    if (onlyIfNew) {
        q.append(" and n.schedule.newEpisode = true");
    }
    q.append(" order by n.schedule.airTime");
    Session session = HibernateUtil.currentSession();
    Query query = session.createQuery(q.toString());
    query.setTimestamp("currentTime", new Date());
    query.setString("lineup", lineup);
    if (limit > 0) {
        query.setMaxResults(limit);
    }
    return query;
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

@SuppressWarnings("unchecked")
public static List<NetworkSchedule> selectNextPrograms(List<String> programId, Date startDate) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getAllNextProgramSchedulesForList");
    query.setTimestamp("startTime", startDate);
    query.setParameterList("programIds", programId, new StringType());
    return query.list();
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

@SuppressWarnings("unchecked")
public static List<NetworkSchedule> selectNextPrograms(String lineup, List<String> programId, Date startDate) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getNextProgramSchedulesForList");
    query.setTimestamp("startTime", startDate);
    query.setParameterList("programIds", programId, new StringType());
    query.setString("lineup", lineup);
    return query.list();
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

@SuppressWarnings("unchecked")
public static List<NetworkSchedule> selectLastPrograms(String lineup, List<String> programId, Date startDate) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getLastProgramSchedulesForList");
    query.setTimestamp("startTime", startDate);
    query.setParameterList("programIds", programId, new StringType());
    query.setString("lineup", lineup);
    return query.list();
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

@SuppressWarnings("unchecked")
public static NetworkSchedule selectLastProgram(String lineup, String programId, Date startDate) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getLastProgramSchedule");
    query.setTimestamp("startTime", startDate);
    query.setString("programId", programId);
    query.setString("lineup", lineup);
    query.setMaxResults(1);//from w  w w  .  j a v a2 s  .c  o  m
    return (NetworkSchedule) query.uniqueResult();
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

@SuppressWarnings("unchecked")
public static NetworkSchedule selectLastShowOrEpisode(String lineup, String showId, Date startDate) {
    assert showId.startsWith("SH") : "showId must start with SH";
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getLastShowSchedule");
    query.setTimestamp("startTime", startDate);
    query.setString("showId", showId);
    query.setString("episodeIdLike", "EP" + showId.substring(2, 10) + "%");
    query.setString("lineup", lineup);
    query.setMaxResults(1);//w w w .j av a  2s.  c o m
    return (NetworkSchedule) query.uniqueResult();
}

From source file:com.knowbout.epg.entities.Schedule.java

License:Apache License

@SuppressWarnings("unchecked")
public static NetworkSchedule selectLastTeamGame(String lineup, String teamId, Date startDate) {
    assert teamId.startsWith("TE") : "teamId must start with TE";
    Program team = Program.selectById(teamId);
    assert (team != null) : "Couldn't find team for programId " + teamId;
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.getLastTeamSchedule");
    query.setTimestamp("startTime", startDate);
    query.setString("sportName", team.getProgramTitle());
    query.setString("teamLike", "%" + team.getEpisodeTitle() + "%");
    query.setString("lineup", lineup);
    query.setMaxResults(1);/*www. jav  a2 s.  c o m*/
    return (NetworkSchedule) query.uniqueResult();
}