Beispiel #1
0
  public void removePlayerFromLeague(League league, Player player) {
    //		List<PlayerLeague> playerLeagues = hibernateTemplate.find(getPlayerLeagueQuery("", "where
    // playerleague.player.id=? and playerleague.league.id=?"),
    //				new Object[] {player.getId(), league.getId()});
    //		if (!playerLeagues.isEmpty())
    //		{
    //		 hibernateTemplate.delete(playerLeagues.iterator().next());
    //		}
    //		if (!playerLeagues.isEmpty())
    //		{
    //			dao.delete(playerLeagues.iterator().next());
    //		}

    Query query =
        getQuery(
            getPlayerLeagueQuery(
                "", "where playerleague.player.id=? and playerleague.league.id=?"));
    query.setParameter(0, player.getId());
    query.setParameter(1, league.getId());

    List<PlayerLeague> playerLeagues = query.list();

    for (PlayerLeague playerLeague : playerLeagues) {
      Query query2 = getQuery("delete from playerLeague where id = ?");
      query2.setParameter(0, playerLeague.getId());

      query2.executeUpdate();
    }
  }
Beispiel #2
0
  public List<League> findLeaguesByPlayer(Player player) {

    //		return hibernateTemplate.find(getPlayerLeagueQuery("select playerleague.league ", "where
    // playerleague.player.id=? order by playerleague.sortOrder, playerleague.league.id desc"),
    //				player.getId());

    Query query =
        getQuery(
            "select pl.league from PlayerLeague pl where pl.player.id=? order by pl.sortOrder, pl.league.id desc");
    query.setParameter(0, player.getId());

    return query.list();
  }
Beispiel #3
0
  public List<League> findLeaguesByPlayer(Player player, boolean isDisplay) {
    //		return hibernateTemplate.find(getPlayerLeagueQuery("select playerleague.league ", "where
    // playerleague.player.id=? and playerleague.displayInNav=? order by playerleague.sortOrder,
    // playerleague.league.id desc"),
    //			new Object[]{player.getId(), isDisplay});

    Query query =
        getQuery(
            getPlayerLeagueQuery(
                "select playerleague.league ",
                "where playerleague.player.id=? and playerleague.displayInNav=? order by playerleague.sortOrder, playerleague.league.id desc"));
    query.setParameter(0, player.getId());
    query.setParameter(1, isDisplay);

    return query.list();
  }