Record Class ParsedSql

java.lang.Object
java.lang.Record
org.litebridge.orm.nativesql.ParsedSql
Record Components:
sql - the SQL statement with named parameters replaced by positional placeholders
bindValueCount - the number of bind values in the statement
bindValueNames - a list of the original names of the bind parameters in the order they appear in the statement

public record ParsedSql(String sql, int bindValueCount, List<String> bindValueNames) extends Record
Represents a parsed SQL statement with positional parameters and their corresponding names.

This class encapsulates a SQL statement where named parameters are replaced with positional placeholders (e.g., "?") and provides a list of the original parameter names. It is used for transforming SQL statements with named parameters into a format that can be executed using standard JDBC APIs.

  • Constructor Details

    • ParsedSql

      public ParsedSql(String sql, int bindValueCount, List<String> bindValueNames)
      Creates an instance of a ParsedSql record class.
      Parameters:
      sql - the value for the sql record component
      bindValueCount - the value for the bindValueCount record component
      bindValueNames - the value for the bindValueNames record component
  • Method Details

    • usesNamedBindParameters

      public boolean usesNamedBindParameters()
      Checks if the SQL statement uses named bind parameters.
      Returns:
      true if the SQL contains named bind parameters; false otherwise.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • sql

      public String sql()
      Returns the value of the sql record component.
      Returns:
      the value of the sql record component
    • bindValueCount

      public int bindValueCount()
      Returns the value of the bindValueCount record component.
      Returns:
      the value of the bindValueCount record component
    • bindValueNames

      public List<String> bindValueNames()
      Returns the value of the bindValueNames record component.
      Returns:
      the value of the bindValueNames record component