public static <R extends UpdatableRecord<R>> int tryCreate(final DSLContext context,
                                                               final R record) {
        LOGGER.debug(() -> "Creating a " + record.getTable() + " record if it doesn't already exist:\n" + record);
        record.attach(context.configuration());
        int result = 0;
        try {
            // Attempt to write the record, which may already be there
            result = record.insert();
        } catch (RuntimeException e) {
            if (isDuplicateKeyException(e)) {
                LOGGER.debug(e::getMessage, e);
            } else {
                // Some other error so just re-throw
                LOGGER.error(e::getMessage, e);
                throw e;
            }
        }
        return result;
    }
Tries to insert record into the database. If it doesn't already exist it will insert the
record and return 1. If it already exists then the unique key violation will be swallowed
and will return 0;
<p>
If you need the persisted version of the record from the database then use
{@link JooqUtil#tryCreate(DataSource, UpdatableRecord, TableField, TableField, TableField, Consumer)}
instead.
</p>
stroom-db-util/src/main/java/stroom/db/util/JooqUtil.java