Methods Summary |
---|
public synchronized RemoteAccountSet | getAccountSet()
return accounts;
|
public RemoteAccount[] | getAccounts()Each customer has one or more accounts stored in an account set.
This method provides those accounts in an array format.
// getPersistents() is all the synchronization we need
RemotePersistent[] obs = accounts.getPersistents();
RemoteAccount[] accts = new RemoteAccount[obs.length];
// This trick is needed to make a Persistent[] an Account[]
for(int i=0; i<obs.length; i++) {
accts[i] = (RemoteAccount)obs[i];
}
return accts;
|
public synchronized java.lang.String | getFirstName()
return first_name;
|
public synchronized java.lang.String | getLastName()
return last_name;
|
protected synchronized imaginary.persist.PersistentPeer | getPersistentPeer()
return Customer.peer;
|
public synchronized void | restore(imaginary.persist.Transaction trans, java.util.Hashtable data)The Customer implementation of the Persistent interface's
restore() method. This takes a Hashtable of values and assigns
them to attributes in the Customer object.
Hashtable hash = new Hashtable();
/*
* Depending on your data store and table structure, the
* Hashtable may have different keys
*/
// Set the ID
setId(((Integer)data.get(CustomerPeer.CUST_ID)).intValue());
// Set the last name
last_name = (String)data.get(CustomerPeer.LAST_NAME);
// Set the first name
first_name = (String)data.get(CustomerPeer.FIRST_NAME);
// Create an account set
try {
accounts = new AccountSet();
}
catch( RemoteException e ) {
throw new PersistenceException(e);
}
// Create a Hashtable that tells the AccountSet what customer ID
// to use for restoring the accounts
hash.put("cust_id", new Integer(getId()));
// Restore all accounts for this customer
accounts.restore(trans, hash);
|
public synchronized void | setId(java.util.Hashtable h)The Persistent interface mandates that implementors
provide a setId(Hashtable) method that pulls the ID out of
a Hashtable and calls setId(int).
// CustomerPeer defines the key for cust_id in the data store
setId(((Integer)h.get(CustomerPeer.CUST_ID)).intValue());
|