@Test public void shouldGetSequentialStateMachineNumbers() { final StateMachineDao repository = JDBI_RULE.DBI.onDemand(StateMachineDao.class); assertThat(repository.getNextId()).isEqualTo("1"); assertThat(repository.getNextId()).isEqualTo("2"); assertThat(repository.getNextId()).isEqualTo("3"); }
public String getNextId() { return getHandle().inTransaction((conn, status) -> { final Query<Map<String, Object>> query = conn.createQuery("SELECT id FROM purefsm_statemachine_id FOR UPDATE"); final Map<String, Object> first = query.first(); final String id = first.get("id").toString(); conn.update("UPDATE purefsm_statemachine_id SET id = id + 1"); return id; }); }
StateMachineDao implements GetHandle { public String getNextId() { return getHandle().inTransaction((conn, status) -> { final Query<Map<String, Object>> query = conn.createQuery("SELECT id FROM purefsm_statemachine_id FOR UPDATE"); final Map<String, Object> first = query.first(); final String id = first.get("id").toString(); conn.update("UPDATE purefsm_statemachine_id SET id = id + 1"); return id; }); } }
StateMachineDao implements GetHandle { public String getNextId() { return getHandle().inTransaction((conn, status) -> { final Query<Map<String, Object>> query = conn.createQuery("SELECT id FROM purefsm_statemachine_id FOR UPDATE"); final Map<String, Object> first = query.first(); final String id = first.get("id").toString(); conn.update("UPDATE purefsm_statemachine_id SET id = id + 1"); return id; }); }  }
StateMachineDao implements GetHandle { public String getNextId() { return getHandle().inTransaction((conn, status) -> { final Query<Map<String, Object>> query = conn.createQuery("SELECT id FROM purefsm_statemachine_id FOR UPDATE"); final Map<String, Object> first = query.first(); final String id = first.get("id").toString(); conn.update("UPDATE purefsm_statemachine_id SET id = id + 1"); return id; }); }  Set<String> getAllIds(); String getNextId(); void insertStateMachineData(String smId, Transition transition); void updateStateMachineData(String smId, Transition transition); boolean removeStateMachineData(String smId); boolean lock(String smId, long timeout); boolean unlock(String smId); Transition getStateMachineData(String smId); }
StateMachineDao implements GetHandle { public String getNextId() { return getHandle().inTransaction((conn, status) -> { final Query<Map<String, Object>> query = conn.createQuery("SELECT id FROM purefsm_statemachine_id FOR UPDATE"); final Map<String, Object> first = query.first(); final String id = first.get("id").toString(); conn.update("UPDATE purefsm_statemachine_id SET id = id + 1"); return id; }); }  Set<String> getAllIds(); String getNextId(); void insertStateMachineData(String smId, Transition transition); void updateStateMachineData(String smId, Transition transition); boolean removeStateMachineData(String smId); boolean lock(String smId, long timeout); boolean unlock(String smId); Transition getStateMachineData(String smId);  }