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.KeywordMatch.java

License:Apache License

public static void deleteOldProgramMatches() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("KeywordMatch.deleteOldProgramMatches");
    // Make sure it has been at least a half hour since the show
    // ended.  We can't remove the KeywordMatch too quickly (e.g., RIGHT
    // after it ends), or the LiveLuceneIndex may not have yet purged the
    // program, and we would get our match all over again (duplicate
    // keyword alerts were a problem)
    query.setTimestamp("thirtyMinutesAgo", new Date(System.currentTimeMillis() - (30 * 60 * 1000)));
    query.executeUpdate();//  w  w w .j  a  v  a  2s . co m
}

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

License:Apache License

public static KeywordMatch getKeywordMatch(long keywordAlertId, String programId) {
    Session session = getSession();
    Query query = session.getNamedQuery("KeywordMatch.getKeywordMatch");
    query.setLong("keywordAlertId", keywordAlertId);
    query.setString("programId", programId);
    return (KeywordMatch) query.uniqueResult();
}

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

License:Apache License

public static void deleteAllMarkedDeleted() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("PendingAlert.deleteAllMarkedDeleted");
    query.executeUpdate();//from  w w  w. j a  v  a  2s  .c  o m
}

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

License:Apache License

public static void deleteOldFired() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("PendingAlert.deleteOldFired");
    query.setTimestamp("currentTime", new Date());
    query.executeUpdate();/* w  ww  .  ja v a 2  s  .c  o  m*/
}

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

License:Apache License

@SuppressWarnings("unchecked")
public static List<PendingAlert> getManualAlertsForUser(User user) {
    Permissions.checkUser(user);//from  w w  w .  j  a v  a2 s . com
    Session session = getSession();
    Query query = session.getNamedQuery("PendingAlert.getManualAlertsForUser");
    query.setLong("userId", user.getUserId());
    return query.list();
}

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

License:Apache License

@SuppressWarnings("unchecked")
public static List<PendingAlert> getExpiredAlerts() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("PendingAlert.getExpiredAlerts");
    query.setTimestamp("currentTime", new Date());
    return query.list();
}

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

License:Apache License

@SuppressWarnings("unchecked")
public static PendingAlert getNextAlert() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("PendingAlert.getNextAlerts");
    ScrollableResults results = query.scroll();
    results.beforeFirst();/*from w  w w  .j ava  2 s.co m*/
    PendingAlert pendingAlert = null;
    if (results.next()) {
        pendingAlert = (PendingAlert) results.get(0);
    }
    results.close();
    return pendingAlert;
}

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

License:Apache License

public static void markDeletedForProgramAlert(ProgramAlert programAlert) {
    Permissions.checkUser(programAlert.getUser());
    Session session = getSession();
    Query query = session.getNamedQuery("PendingAlert.markDeletedForProgramAlert");
    query.setEntity("programAlert", programAlert);
    query.executeUpdate();//from www. j av  a2  s . c om
}

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

License:Apache License

@SuppressWarnings("unchecked")
public static ChunkedResults<ProgramAlert> getAll() {
    Permissions.checkUser(Permissions.SUPERUSER);
    Session session = getSession();
    Query query = session.getNamedQuery("ProgramAlert.getAll");
    return new ChunkedResults<ProgramAlert>(query);
}

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

License:Apache License

public static void markDeletedForProgram(User user, String programId) {
    Permissions.checkUser(user);// w w  w  .  j  a va 2 s  .  c o  m
    Session session = getSession();
    Query query = session.getNamedQuery("ProgramAlert.markDeletedForProgram");
    query.setEntity("user", user);
    query.setString("programId", programId);
    query.executeUpdate();
}