/** * Save the bowl matchups. * * @param matchupBizObjs * @param deletedIds */ public void saveAllBowlMatchups(List<BowlMatchupBo> matchupBizObjs, List<Integer> deletedIds) { Transaction clearPicksTx = session.beginTransaction(); for (Integer matchupIdToDelete : deletedIds) { BowlMatchup matchup = getMatchupById(matchupIdToDelete); matchup.getBowlPicks().clear(); session.save(matchup); } clearPicksTx.commit(); session.flush(); Transaction deleteMatchupTx = session.beginTransaction(); for (Integer matchupIdToDelete : deletedIds) { BowlMatchup matchup = getMatchupById(matchupIdToDelete); session.delete(matchup); } deleteMatchupTx.commit(); session.flush(); Transaction saveTransaction = session.beginTransaction(); for (BowlMatchupBo matchupBo : matchupBizObjs) { BowlMatchup matchup = null; if (matchupBo.getMatchupId() != null) { matchup = this.getMatchupById(matchupBo.getMatchupId()); } else { matchup = new BowlMatchup(); } matchup.setDate(matchupBo.getDate()); matchup.setTitle(matchupBo.getTitle()); matchup.setTeamA(getCfbTeamById(matchupBo.getTeamA().getCfbTeamId())); matchup.setTeamB(getCfbTeamById(matchupBo.getTeamB().getCfbTeamId())); matchup.setTeamASpread(matchupBo.getTeamASpread()); matchup.setTeamBSpread(matchupBo.getTeamBSpread()); matchup.setTeamAScore(matchupBo.getTeamAScore()); matchup.setTeamBScore(matchupBo.getTeamBScore()); if (matchupBo.getWinningTeam() != null) { matchup.setWinningTeam(getCfbTeamById(matchupBo.getWinningTeam().getCfbTeamId())); } matchup.setLockFlag(matchupBo.getLockFlag()); matchup.setLastEditTimestamp(new Date()); matchup.setCreateTimestamp(new Date()); session.saveOrUpdate(matchup); } saveTransaction.commit(); session.flush(); }