Rakesh API

biz.wedoit4u.databeans
Class CustomerTypeBean

java.lang.Object
  extended by biz.wedoit4u.databeans.CustomerTypeBean
All Implemented Interfaces:
java.io.Serializable

public class CustomerTypeBean
extends java.lang.Object
implements java.io.Serializable

A Java Bean that represents a record in the customer_types table. This bean is used to cache the values read from the database, and to make modifications you need to the bean fields, and then send it back to the database for updating the associated record. All instances of this class are cached into a Map object that is stored in the System.getProperties() object under a property with name CACHE_NAME. All instances variables are public except the primary key column customer_type_id and the foreign key column partner_id.

Copyright 2003, Rakesh Vidyadharan

Version:
$Id: CustomerTypeBean.java,v 1.9 2004/05/26 11:42:31 rakesh Exp $
Author:
Rakesh Vidyadharan on 16th September 2003
See Also:
Serialized Form

Field Summary
private static java.util.Map cache
          The Map that is used to cache instances of this bean.
static java.lang.String CACHE_NAME
          A constant that denotes the name of the system property at which all instances of this class are cached.
private  int customerTypeId
          The value in the customer_type_id column.
 java.lang.String description
          The value in the description column.
private static java.lang.Object lockObject
          An object that is used to synchronise modifications to the system cache of instances of these beans.
private  int partnerId
          The value in the partner_id foreign key column.
 java.lang.String type
          The value in the type column.
 
Constructor Summary
private CustomerTypeBean()
          The default constructor.
 
Method Summary
static CustomerTypeBean create(int customerTypeId, java.lang.String type, java.lang.String description, int partnerId)
          Create a new instance of the bean that may be used to create a corresponding record in the customer_types table.
static void delete(CustomerTypeBean cb)
          Delete the specified instance of this class from the system cache as well as from the database.
static java.util.Collection findAll()
          Return a Collection of bean instances that represent all the records in the customer_types table.
static java.util.Collection findByPartner(int partnerId)
          Return a Collection of bean instances that represent all the records in the customer_types table that belong to the specified partner.
 int getCustomerTypeId()
          Returns customerTypeId.
static CustomerTypeBean getInstance(int customerTypeId)
          Fetch the instance of the bean identified by the primary key value specified.
 int getPartnerId()
          Returns partnerId.
 void save()
          Write back all the values in the bean fields to the database.
static void setInstance(CustomerTypeBean ctb)
          Add the specified bean instance to the system cache.
(package private)  void setPartnerId(int partnerId)
          Set partnerId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lockObject

private static final java.lang.Object lockObject
An object that is used to synchronise modifications to the system cache of instances of these beans.


cache

private static final java.util.Map cache
The Map that is used to cache instances of this bean.


CACHE_NAME

public static final java.lang.String CACHE_NAME
A constant that denotes the name of the system property at which all instances of this class are cached.

See Also:
Constant Field Values

customerTypeId

private int customerTypeId
The value in the customer_type_id column.


type

public java.lang.String type
The value in the type column.


description

public java.lang.String description
The value in the description column.


partnerId

private int partnerId
The value in the partner_id foreign key column.

Constructor Detail

CustomerTypeBean

private CustomerTypeBean()
The default constructor. Cannot be directly instantiated.

Method Detail

create

public static final CustomerTypeBean create(int customerTypeId,
                                            java.lang.String type,
                                            java.lang.String description,
                                            int partnerId)
                                     throws CMAException
Create a new instance of the bean that may be used to create a corresponding record in the customer_types table. If you wish the database sequence value be used to populate the customer_type_id value, then specify a value of 0 for customerTypeId. All new instances created are added to the system cache, unless they are created with a customerId value of 0.

Parameters:
customerTypeId - - The primary key value to use.
type - - The code name used to identify the customer type.
description - - A detailed description about the type of customer that is being created.
partnerId - - The foreign key to the partner table.
Throws:
CMAException - - If an attempt is made to create an instance of the object that already exists, as identified by the customerTypeId value.

delete

public static final void delete(CustomerTypeBean cb)
                         throws CMAException
Delete the specified instance of this class from the system cache as well as from the database.

Parameters:
cb - - The bean instance that is to be removed.
Throws:
CMAException - - If errors are encountered while removing the associated record in the database.
See Also:
CustomerTypeHelper.delete( int )

save

public void save()
          throws CMAException
Write back all the values in the bean fields to the database. All the columns in the customer_types table are updated with the values in the bean fields.

Throws:
CMAException - - If errors are encountered while writing the values to the database.

findAll

public static final java.util.Collection findAll()
                                          throws CMAException
Return a Collection of bean instances that represent all the records in the customer_types table.

Returns:
Collection - The collection of java bean instances.
Throws:
CMAException - - If errors are encountered while fetching all the bean instances.

findByPartner

public static final java.util.Collection findByPartner(int partnerId)
                                                throws CMAException
Return a Collection of bean instances that represent all the records in the customer_types table that belong to the specified partner.

Parameters:
partnerId - - The partner_id foreign key value.
Returns:
Collection - The collection of java bean instances.
Throws:
CMAException - - If errors are encountered while fetching all the bean instances.

getInstance

public static final CustomerTypeBean getInstance(int customerTypeId)
                                          throws CMAException
Fetch the instance of the bean identified by the primary key value specified. If the bean instance does not exist in the cache, try to fetch it from the database.

Parameters:
customerTypeId - - The customer_type_id value based upon which to fetch the instance.
Returns:
CustomerTypeBean - The appropriate bean instance.
Throws:
CMAException - - If the specified bean instance is not available in the system cache.

setInstance

public static final void setInstance(CustomerTypeBean ctb)
Add the specified bean instance to the system cache. This method follows the general contract provided by the Map interface in that, if an entry with the same key already exists, then that entry is replaced, or a new one created. This method uses the lockObject to synchronise modifications to the Map cache.

Parameters:
ctb - - The instance that is being added to the system cache.

getCustomerTypeId

public final int getCustomerTypeId()
Returns customerTypeId.

Returns:
int - The value/reference of/to customerTypeId.

getPartnerId

public final int getPartnerId()
Returns partnerId.

Returns:
int - The value/reference of/to partnerId.

setPartnerId

final void setPartnerId(int partnerId)
Set partnerId.

Parameters:
partnerId - - The value to set.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan