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.appeligo.alerts.ProgramAlert.java

License:Apache License

@SuppressWarnings("unchecked")
public static void deleteAllMarkedDeleted() {
    Permissions.checkUser(Permissions.SUPERUSER);
    // PendingAlert.markDeletedWhereProgramAlertMarked(); the update join I'd like to do won't work

    List<ProgramAlert> programAlerts = getAllMarkedDeleted();
    for (ProgramAlert programAlert : programAlerts) {
        PendingAlert.markDeletedForProgramAlert(programAlert);
    }//  www  .  ja  v  a 2 s . c om

    Session session = getSession();
    Query query = session.getNamedQuery("ProgramAlert.deleteAllMarkedDeleted");
    query.executeUpdate();
}

From source file:com.appeligo.alerts.ProgramAlert.java

License:Apache License

private static List<ProgramAlert> getAllMarkedDeleted() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("ProgramAlert.getAllMarkedDeleted");
    List<ProgramAlert> programAlerts = query.list();
    return programAlerts;
}

From source file:com.appeligo.alerts.ProgramAlert.java

License:Apache License

@SuppressWarnings("unchecked")
public static List<ProgramAlert> getByProgramId(User user, String programId) {
    Permissions.checkUser(user);/*from   w  w w. j ava2  s.com*/
    Session session = getSession();
    Query query = session.getNamedQuery("ProgramAlert.getByProgramIdForUser");
    query.setEntity("user", user);
    query.setString("programId", programId);
    List<ProgramAlert> programAlerts = query.list();
    return programAlerts;
}

From source file:com.appeligo.search.entity.Favorite.java

License:Apache License

public static Favorite getTopFavoriteShow(User user) {
    Permissions.checkUser(user);/* w ww .jav a 2s. c om*/
    Session session = getSession();
    Query query = session.getNamedQuery("Favorite.getFavoriteNonEpisodes");
    query.setMaxResults(1);
    query.setEntity("user", user);
    return (Favorite) query.uniqueResult();
}

From source file:com.appeligo.search.entity.Favorite.java

License:Apache License

public static Favorite getTopFavoriteEpisode(User user) {
    Permissions.checkUser(user);//w  ww. j  av a  2 s . co m
    Session session = getSession();
    Query query = session.getNamedQuery("Favorite.getFavoriteEpisodes");
    query.setMaxResults(1);
    query.setEntity("user", user);
    return (Favorite) query.uniqueResult();
}

From source file:com.appeligo.search.entity.Favorite.java

License:Apache License

public static List<Favorite> getFavoriteShows(User user) {
    Permissions.checkUser(user);/*from  w w w  .  j  ava  2  s .  c o m*/
    Session session = getSession();
    Query query = session.getNamedQuery("Favorite.getFavoriteNonEpisodes");
    query.setEntity("user", user);
    return query.list();
}

From source file:com.appeligo.search.entity.Favorite.java

License:Apache License

public static List<Favorite> getFavoriteEpisodes(User user) {
    Permissions.checkUser(user);//from  w  w  w. j  av  a2 s .  c om
    Session session = getSession();
    Query query = session.getNamedQuery("Favorite.getFavoriteEpisodes");
    query.setEntity("user", user);
    return query.list();
}

From source file:com.appeligo.search.entity.Favorite.java

License:Apache License

public static Favorite findFavoriteProgram(User user, String programId) {
    Permissions.checkUser(user);/*  w ww . j  a va 2s. com*/
    Session session = getSession();
    Query query = session.getNamedQuery("Favorite.getProgram");
    query.setEntity("user", user);
    query.setString("programId", programId);
    return (Favorite) query.uniqueResult();
}

From source file:com.appeligo.search.entity.Feedback.java

License:Apache License

@SuppressWarnings("unchecked")
public static List<Feedback> getFeedback() {
    Session session = getSession();
    Query query = session.getNamedQuery("Feedback.getAll");
    return query.list();
}

From source file:com.appeligo.search.entity.Friend.java

License:Apache License

public static Friend findByEmail(User user, String email) {
    Session session = getSession();
    Query query = session.getNamedQuery("Friend.getByEmail");
    query.setString("email", email);
    query.setEntity("user", user);
    return (Friend) query.uniqueResult();
}