Record Class StatementResult

java.lang.Object
java.lang.Record
com.pyranid.StatementResult
Record Components:
rowsReturned - rows returned through a result set, or null if unavailable
rowsAffected - rows affected by a DML/update operation, or null if unavailable

@ThreadSafe public record StatementResult(@Nullable Long rowsReturned, @Nullable Long rowsAffected) extends Record
Statement row-count information observed by Pyranid.

rowsReturned counts rows materialized through a JDBC ResultSet. rowsAffected counts rows changed by a JDBC update-count operation. Some statements have neither value, and some database features can logically have both even if Pyranid can only observe one of them through the current JDBC execution path.

Since:
4.2.0
Author:
Mark Allen
  • Constructor Details

    • StatementResult

      public StatementResult(@Nullable Long rowsReturned, @Nullable Long rowsAffected)
      Creates an instance of a StatementResult record class.
      Parameters:
      rowsReturned - the value for the rowsReturned record component
      rowsAffected - the value for the rowsAffected record component
  • Method Details

    • empty

      public static @NonNull StatementResult empty()
      A singleton result for statements with no row-count information.
      Returns:
      an empty result
    • ofRowsReturned

      public static @NonNull StatementResult ofRowsReturned(@NonNull Long rowsReturned)
      Creates a result with returned-row information.
      Parameters:
      rowsReturned - returned-row count
      Returns:
      a statement result
    • ofRowsAffected

      public static @NonNull StatementResult ofRowsAffected(@NonNull Long rowsAffected)
      Creates a result with affected-row information.
      Parameters:
      rowsAffected - affected-row count
      Returns:
      a statement result
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • rowsReturned

      public @Nullable Long rowsReturned()
      Returns the value of the rowsReturned record component.
      Returns:
      the value of the rowsReturned record component
    • rowsAffected

      public @Nullable Long rowsAffected()
      Returns the value of the rowsAffected record component.
      Returns:
      the value of the rowsAffected record component