Module storm.java

Class PreparedQueryImpl

java.lang.Object
st.orm.template.impl.QueryImpl
st.orm.template.impl.PreparedQueryImpl
All Implemented Interfaces:
AutoCloseable, PreparedQuery, Query

public class PreparedQueryImpl extends QueryImpl implements PreparedQuery
  • Constructor Details

    • PreparedQueryImpl

      public PreparedQueryImpl(st.orm.core.template.PreparedQuery core)
  • Method Details

    • addBatch

      public void addBatch(Data record)
      Description copied from interface: PreparedQuery
      Add a record to the batch.
      Specified by:
      addBatch in interface PreparedQuery
      Parameters:
      record - the record to add to the batch.
    • getGeneratedKeys

      public <ID> Stream<ID> getGeneratedKeys(Class<ID> type)
      Description copied from interface: PreparedQuery
      Returns a stream of generated keys as the result of an insert statement. Returns an empty stream if the insert statement did not generate any keys.

      The returned stream allows for lazy processing, meaning elements are generated only as they are consumed, optimizing resource usage. Note, however, that calling this method does trigger the execution of the underlying query, so it should only be invoked when the query is intended to run. Since the stream holds resources open while in use, it must be closed after usage to prevent resource leaks. As the stream is AutoCloseable, it is recommended to use it within a try-with-resources block.

      Specified by:
      getGeneratedKeys in interface PreparedQuery
      Type Parameters:
      ID - the type of generated keys
      Parameters:
      type - the class of the keys
      Returns:
      a stream of generated keys resulting from an insert statement; returns an empty stream if no keys are generated.
    • close

      public void close()
      Description copied from interface: PreparedQuery
      Close the resources associated with this query.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface PreparedQuery