Rakesh API

biz.wedoit4u.databeans
Class PartnerBean

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

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

A java bean that represents a record in the partners 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 partner_id.

Copyright 2004, Rakesh Vidyadharan

Version:
$Id: PartnerBean.java,v 1.5 2004/05/26 11:42:32 rakesh Exp $
Author:
Rakesh Vidyadharan on 1st January 2004
See Also:
Serialized Form

Field Summary
 char active
          The value in the active column.
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.
 java.util.Date creationDate
          The value in the creation_date column.
 java.lang.String description
          The value in the description column.
 java.lang.String email
          The value in the email column.
 java.util.Date expirationDate
          The value in the expiration_date column.
private static java.lang.Object lockObject
          An object that is used to synchronise modifications to the system cache of instances of these beans.
 java.lang.String mobilePhone
          The value in the mobile_phone column.
private  int partnerId
          The value in the partner_id column.
 java.lang.String partnerName
          The value in the partner_name column.
 java.lang.String password
          The value in the password column.
 java.lang.String telephone
          The value in the telephone column.
 java.lang.String username
          The value in the username column.
 
Constructor Summary
private PartnerBean()
          Default constructor.
 
Method Summary
static PartnerBean create(int partnerId, java.lang.String username, java.lang.String password, char active, java.util.Date expirationDate, java.lang.String partnerName, java.lang.String description, java.lang.String email, java.lang.String telephone, java.lang.String mobilePhone)
          Create a new partners record with the values specified for all the columns in the table.
static void delete(PartnerBean pb)
          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 partners table.
static PartnerBean getInstance(int partnerId)
          Fetch the instance of the bean from the system cache indentified by the primary key column partnerId.
static PartnerBean getInstance(java.lang.String username, java.lang.String password)
          Return the bean instance identified by the username and password values specified.
 int getPartnerId()
          Returns partnerId.
 void save()
          Write back all the values in the bean fields to the database.
static void setInstance(PartnerBean ctb)
          Add the specified bean instance to the system cache.
 
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

partnerId

private int partnerId
The value in the partner_id column.


username

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


password

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


active

public char active
The value in the active column.


creationDate

public java.util.Date creationDate
The value in the creation_date column.


expirationDate

public java.util.Date expirationDate
The value in the expiration_date column.


partnerName

public java.lang.String partnerName
The value in the partner_name column.


description

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


email

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


telephone

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


mobilePhone

public java.lang.String mobilePhone
The value in the mobile_phone column.

Constructor Detail

PartnerBean

private PartnerBean()
Default constructor. Cannot be directly instantiated.

Method Detail

create

public static final PartnerBean create(int partnerId,
                                       java.lang.String username,
                                       java.lang.String password,
                                       char active,
                                       java.util.Date expirationDate,
                                       java.lang.String partnerName,
                                       java.lang.String description,
                                       java.lang.String email,
                                       java.lang.String telephone,
                                       java.lang.String mobilePhone)
                                throws CMAException
Create a new partners record with the values specified for all the columns in the table. If you wish to use the database sequence to generate the partner_id value, specify a value of 0 for the partner_id. Creating a new instance will also add the new instance of the system cache, unless the partnerId value specified is 0.

Parameters:
partnerId - - The partner_id value.
username - - The username value.
password - - The password value.
active - - The active value.
expirationDate - - The expiration_date value.
partnerName - - The partner_name value.
description - - The description value.
email - - The email value.
telephone - - The telephone value.
mobilePhone - - The mobilePhone value.
Throws:
CMAException - - If an attempt is made to create an instance of the object that already exists, as identified by the partnerId value.

save

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

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

delete

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

Parameters:
pb - - The bean instance that is to be removed.
Throws:
CMAException - - If errors are encountered while removing the associated record in the database.

getInstance

public static final PartnerBean getInstance(int partnerId)
                                     throws CMAException
Fetch the instance of the bean from the system cache indentified by the primary key column partnerId.

Parameters:
partnerId - - The primary key value based upon which to find the appropriate bean instance.
Throws:
CMAException - - If the appropriate bean instance is not found.

findAll

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

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

getInstance

public static final PartnerBean getInstance(java.lang.String username,
                                            java.lang.String password)
                                     throws CMAException
Return the bean instance identified by the username and password values specified.

Parameters:
username - - The username value.
password - - The password value.
Throws:
CMAException - - If errors are encountered while fetching the bean instance.

setInstance

public static final void setInstance(PartnerBean 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.

getPartnerId

public final int getPartnerId()
Returns partnerId.

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

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan