Module bus.pager

Class SimpleWithNolock

java.lang.Object
org.miaixz.bus.pager.dialect.replace.SimpleWithNolock
All Implemented Interfaces:
ReplaceSql

public class SimpleWithNolock extends Object implements ReplaceSql
Simple implementation of ReplaceSql to handle SQL Server's `with(nolock)` hint. It replaces `with(nolock)` with a simple placeholder for SQL parsing and then restores it.
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • WITHNOLOCK

      protected String WITHNOLOCK
      Placeholder for `with(nolock)` during SQL parsing.
  • Constructor Details

    • SimpleWithNolock

      public SimpleWithNolock()
  • Method Details

    • replace

      public String replace(String sql)
      Replaces `with(nolock)` clauses in the SQL with a simple placeholder. This is done to prevent parsing errors with SQL parsers that do not understand `with(nolock)`.
      Specified by:
      replace in interface ReplaceSql
      Parameters:
      sql - the original SQL string
      Returns:
      the SQL string with `with(nolock)` replaced by a placeholder
    • restore

      public String restore(String sql)
      Restores the `with(nolock)` clauses in the SQL from their simple placeholders. This is called after SQL parsing and modification.
      Specified by:
      restore in interface ReplaceSql
      Parameters:
      sql - the SQL string with placeholders
      Returns:
      the SQL string with `with(nolock)` restored