}
BaseDao<League> leagueDao = daoResolver.resolve(League.class);
LeagueQuery leagueQuery = new LeagueQuery();
leagueQuery.getEntity().setName(leagueCode);
League league = leagueDao.findUnique(leagueQuery);
if (league.getTeamsHistory() == null) {
league.setTeamsHistory(new ArrayList<LeagueTeamHistory>());
}
LeagueTeamHistory ltHistory = new LeagueTeamHistory();
ltHistory.setLeague(league);
ltHistory.setTeam(team);
ltHistory.setYear(year);
if (!league.getTeamsHistory().contains(ltHistory)) {
league.getTeamsHistory().add(ltHistory);
}
if (league.getVersion() == null) {
log.append("persist: " + league);
log.append("\n");
leagueDao.persist(league);
} else {
log.append("merge: " + league);