@Test public void builtTryLockSql() throws IOException { PostgresIntervalLock postgresIntervalLock = new PostgresIntervalLock(dataSource); String tryLockSQL = postgresIntervalLock.buildTryLockSql(new TableConfig()); assertEquals( "INSERT INTO \"public\".\"lock\" (\"name\", \"owner\", \"locked_at\", \"locked_till\")\n" + "VALUES(:name, :owner, NOW(), NOW() + :locked_till * interval '1 second')\n" + "ON CONFLICT DO NOTHING", tryLockSQL); }
@Override protected String buildTryLockSql(final TableConfig tableConfig) { return new StringBuilder().append("INSERT INTO ") .append(getSafeName(tableConfig.getSchema())) .append(".") .append(getSafeName(tableConfig.getTable())) .append(" (") .append(getSafeName(tableConfig.getName())) .append(", ") .append(getSafeName(tableConfig.getOwner())) .append(", ") .append(getSafeName(tableConfig.getAt())) .append(", ") .append(getSafeName(tableConfig.getTill())) .append(")\n") .append("VALUES(") .append(getValueName(tableConfig.getName())) .append(", ") .append(getValueName(tableConfig.getOwner())) .append(", NOW(), ") .append("NOW() + :" + tableConfig.getTill() + " * interval '1 second'") .append(")\n") .append("ON CONFLICT DO NOTHING") .toString(); }
PostgresIntervalLock extends JdbcIntervalLock { @Override protected String buildTryLockSql(final TableConfig tableConfig) { return new StringBuilder().append("INSERT INTO ") .append(getSafeName(tableConfig.getSchema())) .append(".") .append(getSafeName(tableConfig.getTable())) .append(" (") .append(getSafeName(tableConfig.getName())) .append(", ") .append(getSafeName(tableConfig.getOwner())) .append(", ") .append(getSafeName(tableConfig.getAt())) .append(", ") .append(getSafeName(tableConfig.getTill())) .append(")\n") .append("VALUES(") .append(getValueName(tableConfig.getName())) .append(", ") .append(getValueName(tableConfig.getOwner())) .append(", NOW(), ") .append("NOW() + :" + tableConfig.getTill() + " * interval '1 second'") .append(")\n") .append("ON CONFLICT DO NOTHING") .toString(); } }
PostgresIntervalLock extends JdbcIntervalLock { @Override protected String buildTryLockSql(final TableConfig tableConfig) { return new StringBuilder().append("INSERT INTO ") .append(getSafeName(tableConfig.getSchema())) .append(".") .append(getSafeName(tableConfig.getTable())) .append(" (") .append(getSafeName(tableConfig.getName())) .append(", ") .append(getSafeName(tableConfig.getOwner())) .append(", ") .append(getSafeName(tableConfig.getAt())) .append(", ") .append(getSafeName(tableConfig.getTill())) .append(")\n") .append("VALUES(") .append(getValueName(tableConfig.getName())) .append(", ") .append(getValueName(tableConfig.getOwner())) .append(", NOW(), ") .append("NOW() + :" + tableConfig.getTill() + " * interval '1 second'") .append(")\n") .append("ON CONFLICT DO NOTHING") .toString(); } PostgresIntervalLock(DataSource dataSource);  PostgresIntervalLock(
      NamedParameterJdbcTemplate jdbcTemplate);  PostgresIntervalLock(DataSource dataSource, TableConfig tableConfig);  PostgresIntervalLock(NamedParameterJdbcTemplate jdbcTemplate, TableConfig tableConfig); }
PostgresIntervalLock extends JdbcIntervalLock { @Override protected String buildTryLockSql(final TableConfig tableConfig) { return new StringBuilder().append("INSERT INTO ") .append(getSafeName(tableConfig.getSchema())) .append(".") .append(getSafeName(tableConfig.getTable())) .append(" (") .append(getSafeName(tableConfig.getName())) .append(", ") .append(getSafeName(tableConfig.getOwner())) .append(", ") .append(getSafeName(tableConfig.getAt())) .append(", ") .append(getSafeName(tableConfig.getTill())) .append(")\n") .append("VALUES(") .append(getValueName(tableConfig.getName())) .append(", ") .append(getValueName(tableConfig.getOwner())) .append(", NOW(), ") .append("NOW() + :" + tableConfig.getTill() + " * interval '1 second'") .append(")\n") .append("ON CONFLICT DO NOTHING") .toString(); } PostgresIntervalLock(DataSource dataSource);  PostgresIntervalLock(
      NamedParameterJdbcTemplate jdbcTemplate);  PostgresIntervalLock(DataSource dataSource, TableConfig tableConfig);  PostgresIntervalLock(NamedParameterJdbcTemplate jdbcTemplate, TableConfig tableConfig); @Override boolean tryLock(final LockConfig lockConfig); }
PostgresIntervalLock extends JdbcIntervalLock { @Override protected String buildTryLockSql(final TableConfig tableConfig) { return new StringBuilder().append("INSERT INTO ") .append(getSafeName(tableConfig.getSchema())) .append(".") .append(getSafeName(tableConfig.getTable())) .append(" (") .append(getSafeName(tableConfig.getName())) .append(", ") .append(getSafeName(tableConfig.getOwner())) .append(", ") .append(getSafeName(tableConfig.getAt())) .append(", ") .append(getSafeName(tableConfig.getTill())) .append(")\n") .append("VALUES(") .append(getValueName(tableConfig.getName())) .append(", ") .append(getValueName(tableConfig.getOwner())) .append(", NOW(), ") .append("NOW() + :" + tableConfig.getTill() + " * interval '1 second'") .append(")\n") .append("ON CONFLICT DO NOTHING") .toString(); } PostgresIntervalLock(DataSource dataSource);  PostgresIntervalLock(
      NamedParameterJdbcTemplate jdbcTemplate);  PostgresIntervalLock(DataSource dataSource, TableConfig tableConfig);  PostgresIntervalLock(NamedParameterJdbcTemplate jdbcTemplate, TableConfig tableConfig); @Override boolean tryLock(final LockConfig lockConfig);  }