class UpgradeDAO {

  @RequiresSession
  public UpgradeEntity findLastUpgradeForCluster(long clusterId, Direction direction) {
    TypedQuery<UpgradeEntity> query = entityManagerProvider.get().createNamedQuery(
        "UpgradeEntity.findLatestForClusterInDirection", UpgradeEntity.class);
    query.setMaxResults(1);
    query.setParameter("clusterId", clusterId);
    query.setParameter("direction", direction);

    return daoUtils.selectSingle(query);
  }

}