Class PersistenceSession

java.lang.Object
de.calamanari.pk.lazyload.PersistenceSession

public class PersistenceSession
extends java.lang.Object
Persistence Session - supplementary class for LAZY LOAD demonstration
Placeholder for some kind of persistence management.
Author:
Karl Eilebrecht
  • Constructor Summary

    Constructors
    Constructor Description
    PersistenceSession()  
  • Method Summary

    Modifier and Type Method Description
    static void addInvoice​(java.lang.String invoiceId, java.lang.String amountClaimed, java.lang.String debtorName, java.lang.String street, java.lang.String zipCode, java.lang.String city)
    Method to fill-in test data
    void close()
    closes the persistence session
    java.util.List<Invoice> findAllInvoices()
    Returns a list of all invoices, using lazy load
    java.util.List<Invoice> findAllInvoices​(boolean lazy)
    Returns a list of all invoices
    Invoice findInvoice​(java.lang.String invoiceId)
    finds the invoice in the database by id
    void loadLazyFields​(Invoice invoice)
    Loads the data for the lazy load fields from the database and sets the fields

    Methods inherited from class java.lang.Object

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

  • Method Details

    • addInvoice

      public static void addInvoice​(java.lang.String invoiceId, java.lang.String amountClaimed, java.lang.String debtorName, java.lang.String street, java.lang.String zipCode, java.lang.String city)
      Method to fill-in test data
      Parameters:
      invoiceId - identifier
      amountClaimed - monetary value to be payed by the debtor
      debtorName - name of the person who has to pay
      street - address field
      zipCode - address field
      city - address field
    • findInvoice

      public Invoice findInvoice​(java.lang.String invoiceId)
      finds the invoice in the database by id
      Parameters:
      invoiceId - identifier
      Returns:
      invoice or null if not found
    • findAllInvoices

      public java.util.List<Invoice> findAllInvoices​(boolean lazy)
      Returns a list of all invoices
      Parameters:
      lazy - if true enable lazy load, otherwise load all
      Returns:
      list of invoice instances
    • findAllInvoices

      public java.util.List<Invoice> findAllInvoices()
      Returns a list of all invoices, using lazy load
      Returns:
      list of invoice instances
    • loadLazyFields

      public void loadLazyFields​(Invoice invoice)
      Loads the data for the lazy load fields from the database and sets the fields
      Parameters:
      invoice - instance of the invoice to be loaded
    • close

      public void close()
      closes the persistence session