Example usage for org.hibernate Session getNamedQuery

List of usage examples for org.hibernate Session getNamedQuery

Introduction

In this page you can find the example usage for org.hibernate Session getNamedQuery.

Prototype

org.hibernate.Query getNamedQuery(String queryName);

Source Link

Document

Create a Query instance for the named query.

Usage

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 ww  w . j  a  va  2 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);/*from w w w  .  j  a  v a  2 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 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);/*from www  . j a  v  a2  s.c  om*/
    return (NetworkSchedule) query.uniqueResult();
}

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

License:Apache License

public static int deleteAfter(Date date) {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Schedule.deleteByDate");
    query.setTimestamp("date", date);
    int count = query.executeUpdate();
    return count;
}

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

License:Apache License

public static List<Station> selectAll() {
    Session session = HibernateUtil.currentSession();
    Query query = session.getNamedQuery("Station.selectAll");
    List<Station> list = query.list();
    return list;//  w  w w  . j  a  v  a 2 s  . c om
}

From source file:com.levinas.ecole.dao.ActiviteDaoImpl.java

@Override
public HashMap findAll() {
    Session session = sessionFactory.getCurrentSession();
    HashMap result = new HashMap();
    Query query = session.getNamedQuery("Activite.findAll");
    double nbResult = query.list().size();
    List listItems = query.list();

    result.put("items", listItems);
    //result.put("page_count", Math.ceil(nbResult/iRpp.doubleValue()));
    result.put("total_items", nbResult);

    return result;
}

From source file:com.levinas.ecole.dao.ActiviteDaoImpl.java

@Override
public Activite findByIdactivite(int idActivite) {
    Session session = sessionFactory.getCurrentSession();
    Query query = session.getNamedQuery("Activite.findByIdactivite");
    query.setParameter("idactivite", idActivite);
    return (Activite) query.uniqueResult();
}

From source file:com.levinas.ecole.dao.AnneeScolaireDaoImpl.java

@Override
public HashMap findAll() {
    Session session = sessionFactory.getCurrentSession();
    HashMap result = new HashMap();
    Query query = session.getNamedQuery("AnneeScolaire.findAll");
    double nbResult = query.list().size();
    List listItems = query.list();

    result.put("items", listItems);
    //result.put("page_count", Math.ceil(nbResult/iRpp.doubleValue()));
    result.put("total_items", nbResult);

    return result;
}