Class CheckoutRepository

java.lang.Object
com.homannsoftware.transactions.CheckoutRepository

@Repository public class CheckoutRepository extends Object
Executes parameterized SQL against the lab's single DataSource.
  • Constructor Details

    • CheckoutRepository

      public CheckoutRepository(org.springframework.jdbc.core.JdbcTemplate jdbc)
      Creates the SQL adapter.
      Parameters:
      jdbc - Spring's transaction-aware JDBC helper
  • Method Details

    • reserve

      public boolean reserve(String sku, int quantity)
      Decrements stock only when enough stock is still available.
      Parameters:
      sku - product identifier
      quantity - positive amount, validated by the service
      Returns:
      true if one inventory row was updated
    • recordOrder

      public void recordOrder(String orderRef, String sku, int quantity)
      Inserts an order; a duplicate reference is a database constraint error.
      Parameters:
      orderRef - unique order reference
      sku - reserved product
      quantity - reserved amount