Associating an Address with a Customer.

COMPONENT JAVA
Applying Design Patterns to JDBC: Building a Lightweight Object-Relational Mapping Framework
Frank Sauer
Listing 4. Associating an Address with a Customer.


class InsertDefaultAddress
       extends DefaultSQLOperation
       implements SQLConstants {

   private Customer c = null;

   InsertDefaultAddress (Customer c) {
      super(insertDefaultAddress,
               insertDefaultAddressColumns);
      this.c = c;
      // map columns from Address object
      setPersistable(c.getDefaultAddress());
   }

   protected Map getProperties() {
      Map m = super.getProperties();
      m.put(ADDRESS_LASTUPDATED,
               new java.util.Date());
      // make the link to the customer
      m.put(ADDRESS_CUSTOMER,
               new BigDecimal(c.getId()));
      return m;
   }
  }

Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.