private void createMissingTickets(Event event) { int existingTickets = ticketRepository.countExistingTicketsForEvent(event.getId()); if (existingTickets < event.getAvailableSeats()) { MapSqlParameterSource[] tickets = EventUtil.generateEmptyTickets( event, new Date(), event.getAvailableSeats() - existingTickets) .toArray(MapSqlParameterSource[]::new); jdbc.batchUpdate(ticketRepository.bulkTicketInitialization(), tickets); } }
void fillTicketsGender() { List<String> ticketIds = jdbc.queryForList( "select uuid from ticket where status not in ('FREE','PENDING', 'PRE_RESERVED') and gender is null and tshirt_size is not null", new EmptySqlParameterSource(), String.class); ticketIds.forEach( uuid -> transactionTemplate.execute( status -> { Ticket ticket = ticketRepository.findByUUID(uuid); String gender = ticket.getTshirtSize().endsWith("-F") ? "F" : "M"; jdbc.update( "update ticket set gender = :gender where uuid = :uuid", new MapSqlParameterSource("uuid", uuid).addValue("gender", gender)); return null; })); }