@@ -254,14 +254,14 @@ public String getDeleteLockSqlString(String tableName) {
254254 }
255255 }
256256
257- public void upsertLockEntry (Connection conn , String tableName , String key , String owner , LocalDateTime expiresAt ) throws SQLException {
257+ public void upsertLockEntry (Connection conn , String tableName , String key , String owner , String lockStatus , LocalDateTime expiresAt ) throws SQLException {
258258 String sql = getInsertOrUpdateLockSqlString (tableName );
259259
260260 if (sqlDialect == SqlDialect .DB2 ) {
261261 // UPDATE first
262262 try (PreparedStatement update = conn .prepareStatement (
263263 "UPDATE " + tableName + " SET status = ?, owner = ?, expires_at = ? WHERE lock_key = ?" )) {
264- update .setString (1 , LockStatus . LOCK_HELD . name () );
264+ update .setString (1 , lockStatus );
265265 update .setString (2 , owner );
266266 update .setTimestamp (3 , Timestamp .valueOf (expiresAt ));
267267 update .setString (4 , key );
@@ -275,7 +275,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
275275 try (PreparedStatement insert = conn .prepareStatement (
276276 "INSERT INTO " + tableName + " (lock_key, status, owner, expires_at) VALUES (?, ?, ?, ?)" )) {
277277 insert .setString (1 , key );
278- insert .setString (2 , LockStatus . LOCK_HELD . name () );
278+ insert .setString (2 , lockStatus );
279279 insert .setString (3 , owner );
280280 insert .setTimestamp (4 , Timestamp .valueOf (expiresAt ));
281281 insert .executeUpdate ();
@@ -287,7 +287,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
287287 // Try UPDATE first
288288 try (PreparedStatement update = conn .prepareStatement (
289289 "UPDATE " + tableName + " SET status = ?, owner = ?, expires_at = ? WHERE lock_key = ?" )) {
290- update .setString (1 , LockStatus . LOCK_HELD . name () );
290+ update .setString (1 , lockStatus );
291291 update .setString (2 , owner );
292292 update .setTimestamp (3 , Timestamp .valueOf (expiresAt ));
293293 update .setString (4 , key );
@@ -301,7 +301,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
301301 try (PreparedStatement insert = conn .prepareStatement (
302302 "INSERT INTO " + tableName + " (lock_key, status, owner, expires_at) VALUES (?, ?, ?, ?)" )) {
303303 insert .setString (1 , key );
304- insert .setString (2 , LockStatus . LOCK_HELD . name () );
304+ insert .setString (2 , lockStatus );
305305 insert .setString (3 , owner );
306306 insert .setTimestamp (4 , Timestamp .valueOf (expiresAt ));
307307 insert .executeUpdate ();
@@ -313,12 +313,12 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
313313 // For SQL Server/Sybase, use Statement and format SQL
314314 try (Statement stmt = conn .createStatement ()) {
315315 String formattedSql = sql
316- .replaceFirst ("\\ ?" , "'" + LockStatus . LOCK_HELD . name () + "'" )
316+ .replaceFirst ("\\ ?" , "'" + lockStatus + "'" )
317317 .replaceFirst ("\\ ?" , "'" + owner + "'" )
318318 .replaceFirst ("\\ ?" , "'" + Timestamp .valueOf (expiresAt ) + "'" )
319319 .replaceFirst ("\\ ?" , "'" + key + "'" )
320320 .replaceFirst ("\\ ?" , "'" + key + "'" )
321- .replaceFirst ("\\ ?" , "'" + LockStatus . LOCK_HELD . name () + "'" )
321+ .replaceFirst ("\\ ?" , "'" + lockStatus + "'" )
322322 .replaceFirst ("\\ ?" , "'" + owner + "'" )
323323 .replaceFirst ("\\ ?" , "'" + Timestamp .valueOf (expiresAt ) + "'" );
324324 stmt .execute (formattedSql );
@@ -328,7 +328,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
328328
329329 if (sqlDialect == SqlDialect .FIREBIRD ) {
330330 try (PreparedStatement ps = conn .prepareStatement (sql )) {
331- ps .setString (1 , LockStatus . LOCK_HELD . name () );
331+ ps .setString (1 , lockStatus );
332332 ps .setString (2 , owner );
333333 ps .setTimestamp (3 , Timestamp .valueOf (expiresAt ));
334334 ps .setString (4 , key );
@@ -337,7 +337,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
337337 String insertSql = "INSERT INTO " + tableName + " (lock_key, status, owner, expires_at) VALUES (?, ?, ?, ?)" ;
338338 try (PreparedStatement ins = conn .prepareStatement (insertSql )) {
339339 ins .setString (1 , key );
340- ins .setString (2 , LockStatus . LOCK_HELD . name () );
340+ ins .setString (2 , lockStatus );
341341 ins .setString (3 , owner );
342342 ins .setTimestamp (4 , Timestamp .valueOf (expiresAt ));
343343 ins .executeUpdate ();
@@ -352,7 +352,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
352352 try (PreparedStatement insert = conn .prepareStatement (
353353 "INSERT INTO " + tableName + " (lock_key, status, owner, expires_at) VALUES (?, ?, ?, ?)" )) {
354354 insert .setString (1 , key );
355- insert .setString (2 , LockStatus . LOCK_HELD . name () );
355+ insert .setString (2 , lockStatus );
356356 insert .setString (3 , owner );
357357 insert .setTimestamp (4 , Timestamp .valueOf (expiresAt ));
358358 insert .executeUpdate ();
@@ -364,7 +364,7 @@ public void upsertLockEntry(Connection conn, String tableName, String key, Strin
364364 // Default case for other dialects
365365 try (PreparedStatement ps = conn .prepareStatement (sql )) {
366366 ps .setString (1 , key );
367- ps .setString (2 , LockStatus . LOCK_HELD . name () );
367+ ps .setString (2 , lockStatus );
368368 ps .setString (3 , owner );
369369 ps .setTimestamp (4 , Timestamp .valueOf (expiresAt ));
370370 ps .executeUpdate ();
0 commit comments