Source:
<code>private IngestionPersistenceResult persistIngestion(long articlePk, ArticleMetadata articleMetadata) { Journal journal = fetchJournal(articleMetadata); return hibernateTemplate.execute(session -> { SQLQuery findNextIngestionNumber = session.createSQLQuery( "SELECT MAX(ingestionNumber) FROM articleIngestion WHERE articleId = :articleId"); findNextIngestionNumber.setParameter("articleId", articlePk); Number maxIngestionNumber = (Number) findNextIngestionNumber.uniqueResult(); int nextIngestionNumber = (maxIngestionNumber == null) ? FIRST_INGESTION_NUMBER : maxIngestionNumber.intValue() + 1; SQLQuery insertEvent = session.createSQLQuery("" + "INSERT INTO articleIngestion (articleId, ingestionNumber, title, publicationDate, revisionDate, articleType, journalId) " + "VALUES (:articleId, :ingestionNumber, :title, :publicationDate, :revisionDate, :articleType, :journalId)"); insertEvent.setParameter("articleId", articlePk); insertEvent.setParameter("ingestionNumber", nextIngestionNumber); insertEvent.setParameter("title", articleMetadata.getTitle()); insertEvent.setParameter("publicationDate", java.sql.Date.valueOf(articleMetadata.getPublicationDate())); <START> insertEvent.setParameter("revisionDate", java.sql.Date.valueOf(articleMetadata.getRevisionDate())); <END> insertEvent.setParameter("articleType", articleMetadata.getArticleType()); insertEvent.setParameter("journalId", journal.getJournalId()); insertEvent.executeUpdate(); long pk = getLastInsertId(session); return new IngestionPersistenceResult(pk, nextIngestionNumber); }); }</code><technical_language>Null check needed here. This suggests articleMetadata.getRevisionDate() return Optional remember, mentioned in <LINK_0> do this consistently ArticleMetadata fields</technical_language>

Target:
private IngestionPersistenceResult persistIngestion(long articlePk, ArticleMetadata articleMetadata) { Journal journal = fetchJournal(articleMetadata); return hibernateTemplate.execute(session -> { SQLQuery findNextIngestionNumber = session.createSQLQuery( "SELECT MAX(ingestionNumber) FROM articleIngestion WHERE articleId = :articleId"); findNextIngestionNumber.setParameter("articleId", articlePk); Number maxIngestionNumber = (Number) findNextIngestionNumber.uniqueResult(); int nextIngestionNumber = (maxIngestionNumber == null) ? FIRST_INGESTION_NUMBER : maxIngestionNumber.intValue() + 1; SQLQuery insertEvent = session.createSQLQuery("" + "INSERT INTO articleIngestion (articleId, ingestionNumber, title, publicationDate, revisionDate, articleType, journalId) " + "VALUES (:articleId, :ingestionNumber, :title, :publicationDate, :revisionDate, :articleType, :journalId)"); insertEvent.setParameter("articleId", articlePk); insertEvent.setParameter("ingestionNumber", nextIngestionNumber); insertEvent.setParameter("title", articleMetadata.getTitle()); insertEvent.setParameter("publicationDate", java.sql.Date.valueOf(articleMetadata.getPublicationDate())); insertEvent.setParameter("revisionDate", (articleMetadata.getRevisionDate() == null ? null : java.sql.Date.valueOf(articleMetadata.getRevisionDate()))); insertEvent.setParameter("articleType", articleMetadata.getArticleType()); insertEvent.setParameter("journalId", journal.getJournalId()); insertEvent.executeUpdate(); long pk = getLastInsertId(session); return new IngestionPersistenceResult(pk, nextIngestionNumber); }); }