HiveSemaphore hs;
if (doesHiveSemaphoreExist())
hs = get();
else {
JdbcTemplate j = getJdbcTemplate();
hs = new HiveSemaphoreImpl(Status.writable, 1);
Object[] parameters = new Object[]{hs.getStatus().getValue(), hs.getRevision()};
try {
j.update("INSERT INTO semaphore_metadata (status,revision) VALUES (?,?)", parameters);
} catch (BadSqlGrammarException e) {
throw new HiveSemaphoreNotFound(e.getMessage());