Class DataManager

java.lang.Object
de.calamanari.pk.optimisticofflinelock.DataManager

public class DataManager
extends java.lang.Object
Data Manager - handles persistence in this OPTIMISTIC OFFLINE LOCK example
Placeholder for any kind of database access management (i.e. DAO is compatible with OPTIMISTIC OFFLINE LOCK pattern).
Author:
Karl Eilebrecht
  • Constructor Summary

    Constructors
    Constructor Description
    DataManager​(javax.sql.DataSource dataSource)
    Creates a new instance on the given dataSource
  • Method Summary

    Modifier and Type Method Description
    void addCustomer​(int customerId, java.lang.String firstName, java.lang.String lastName, java.lang.String street, java.lang.String zipCode, java.lang.String city)
    Create a customer, in this example used to add test data
    Customer findCustomerById​(int customerId)
    Returns the corresponding customer for the given id
    void storeCustomer​(Customer customer)
    Writes the customer data to the database (updates existing record).

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DataManager

      public DataManager​(javax.sql.DataSource dataSource)
      Creates a new instance on the given dataSource
      Parameters:
      dataSource - underlying data source (DB)
  • Method Details

    • addCustomer

      public void addCustomer​(int customerId, java.lang.String firstName, java.lang.String lastName, java.lang.String street, java.lang.String zipCode, java.lang.String city)
      Create a customer, in this example used to add test data
      Parameters:
      customerId - identifier
      firstName - person's first name
      lastName - person's last name
      street - address field
      zipCode - address field
      city - address field
    • findCustomerById

      public Customer findCustomerById​(int customerId)
      Returns the corresponding customer for the given id
      Parameters:
      customerId - identifier
      Returns:
      Customer or null if not found
    • storeCustomer

      public void storeCustomer​(Customer customer)
      Writes the customer data to the database (updates existing record).
      Parameters:
      customer - instance to be stored in the database