Source:
public void addOrUpdateAlert(final Alert alert, final Organization organization) { assertIsOpen(); LOGGER.debug() .setMessage("Upserting alert") .addData("alert", alert) .log(); try (Transaction transaction = Ebean.beginTransaction()) { models.ebean.Alert ebeanAlert = Ebean.find(models.ebean.Alert.class) .where() .eq("uuid", alert.getId()) .eq("organization.uuid", organization.getId()) .findUnique(); boolean isNewAlert = false; if (ebeanAlert == null) { ebeanAlert = new models.ebean.Alert(); isNewAlert = true; } ebeanAlert.setOrganization(models.ebean.Organization.findByOrganization(organization)); ebeanAlert.setCluster(alert.getCluster()); ebeanAlert.setUuid(alert.getId()); ebeanAlert.setMetric(alert.getMetric()); ebeanAlert.setContext(alert.getContext()); ebeanAlert.setNagiosExtension(convertToEbeanNagiosExtension(alert.getNagiosExtension())); ebeanAlert.setName(alert.getName()); ebeanAlert.setOperator(alert.getOperator()); ebeanAlert.setPeriod(alert.getPeriod().toStandardSeconds().getSeconds()); ebeanAlert.setQuantityValue(alert.getValue().getValue()); ebeanAlert.setQuantityUnit(alert.getValue().getUnit().orNull()); ebeanAlert.setStatistic(alert.getStatistic()); ebeanAlert.setService(alert.getService()); _alertQueryGenerator.saveAlert(ebeanAlert); transaction.commit(); LOGGER.info() .setMessage("Upserted alert") .addData("alert", alert) .addData("isCreated", isNewAlert) .log(); } catch (final IOException | RuntimeException e) { LOGGER.error() .setMessage("Failed to upsert alert") .addData("alert", alert) .setThrowable(e) .log(); throw new PersistenceException(e); } }

Target:
public void addOrUpdateAlert(final Alert alert, final Organization organization) { assertIsOpen(); LOGGER.debug() .setMessage("Upserting alert") .addData("alert", alert) .addData("organization", organization) .log(); try (Transaction transaction = Ebean.beginTransaction()) { models.ebean.Alert ebeanAlert = Ebean.find(models.ebean.Alert.class) .where() .eq("uuid", alert.getId()) .eq("organization.uuid", organization.getId()) .findUnique(); boolean isNewAlert = false; if (ebeanAlert == null) { ebeanAlert = new models.ebean.Alert(); isNewAlert = true; } ebeanAlert.setOrganization(models.ebean.Organization.findByOrganization(organization)); ebeanAlert.setCluster(alert.getCluster()); ebeanAlert.setUuid(alert.getId()); ebeanAlert.setMetric(alert.getMetric()); ebeanAlert.setContext(alert.getContext()); ebeanAlert.setNagiosExtension(convertToEbeanNagiosExtension(alert.getNagiosExtension())); ebeanAlert.setName(alert.getName()); ebeanAlert.setOperator(alert.getOperator()); ebeanAlert.setPeriod(alert.getPeriod().toStandardSeconds().getSeconds()); ebeanAlert.setQuantityValue(alert.getValue().getValue()); ebeanAlert.setQuantityUnit(alert.getValue().getUnit().orNull()); ebeanAlert.setStatistic(alert.getStatistic()); ebeanAlert.setService(alert.getService()); _alertQueryGenerator.saveAlert(ebeanAlert); transaction.commit(); LOGGER.info() .setMessage("Upserted alert") .addData("alert", alert) .addData("organization", organization) .addData("isCreated", isNewAlert) .log(); } catch (final IOException | RuntimeException e) { LOGGER.error() .setMessage("Failed to upsert alert") .addData("alert", alert) .addData("organization", organization) .setThrowable(e) .log(); throw new PersistenceException(e); } }