public static <T> Optional<T> getMaxId(final DSLContext context,
                                           final Table<?> table,
                                           final Field<T> idField) {
        return context
                .select(DSL.max(idField))
                .from(table)
                .fetchOptional()
                .map(Record1::value1);
    }
Check that the datasource is not currently being used by the current thread. The main point of this check is to
ensure that operations on a datasource are not nested as this can lead to exhaustion of connections from a
datasource connection pool and produce a deadlock. It is generally ok for separate threads to get connections
from the datasource as a connection should become available once one thread has released a connection back to the
pool. However, nested calls, particularly recursive ones, will quickly starve a connection pool and lock the
system.

@param dataSource The datasource to check.
stroom-db-util/src/main/java/stroom/db/util/JooqUtil.java