au.gov.tas.dpiwe.mr.test.aggregation
Class MrCardHome

java.lang.Object
  extended by au.gov.tas.dpiwe.mr.test.aggregation.MrCardHome
All Implemented Interfaces:
FieldEqualFinder, LocalHome, CardHome, EJBLocalHome

public final class MrCardHome
extends Object
implements CardHome, LocalHome, FieldEqualFinder

This is an implementation of the CardHome interface which allows CardObjects to be created and retrieved from persistent storage.

Version:
1.0.1.8
Author:
Kade Hansson, au.gov.tas.dpiwe.mr.tool.DeploymentTool

Field Summary
protected  Container container
          The container to which this bean home interface belongs.
protected static ConstrainedField[] defaultConstrainedFields
          The starter culture for constrained fields.
protected  MetaData metadata
          The metadata object describing the beans residing in this home.
 
Constructor Summary
MrCardHome(Container container)
          Construct a new home interface instance.
 
Method Summary
 CardObject create(CardKey cardID)
          Creates a new bean object instance.
 CardObject findAllByPrimaryKey(CardKey cardID)
          Finds an existing bean object, and all its related objects.
 List findAllWhereFieldsEqual(DeckKey deckID)
          Selects many existing bean objects whose fields equal those specified, along with all of their related objects.
 CardObject findByPrimaryKey(CardKey cardID)
          Finds an existing bean object.
 List findWhereFieldsEqual(DeckKey deckID)
          Selects many existing bean objects whose fields equal those specified.
 Collection getFieldNamesForLongestFindWhereFieldsEqual()
          Internal method used by the container to discover the meaning of parameters to the longest findWhereFieldsEqual() method, which is the method used to look up beans with given a foreign key.
 Class[] getFieldTypesForLongestFindWhereFieldsEqual()
          Internal method used by the container to discover the types of parameters for the longest findWhereFieldsEqual() method, which is the method used to look up beans with given a foreign key.
 MetaData getMetaData()
          Gets the metadata object associated with beans from this home.
 Object invokeOnServer(Method method, Object[] parameters)
          Executes a method of this home interface on the server.
 boolean lock()
          Locks this home interface on the server, preventing updates until the current transaction commits (or rolls back.)
 void remove(Object cardID)
          Removes the bean object with the specified primary key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

protected Container container
The container to which this bean home interface belongs.


metadata

protected MetaData metadata
The metadata object describing the beans residing in this home.


defaultConstrainedFields

protected static final ConstrainedField[] defaultConstrainedFields
The starter culture for constrained fields.

Constructor Detail

MrCardHome

public MrCardHome(Container container)
Construct a new home interface instance.

This is done by the container during the addType() method, so external clients should not call this constructor directly. If a client requires access to the home interface instance created by the container at start-up then it should use the getHomeForEntityBean() method.

Parameters:
container - the container to which the new home interface belongs.
Method Detail

getMetaData

public MetaData getMetaData()
Gets the metadata object associated with beans from this home.

The metadata object provides access to field types and lengths, and other information about the classes supporting a bean type.

Specified by:
getMetaData in interface LocalHome
Returns:
the metadata as parsed.

create

public CardObject create(CardKey cardID)
                  throws EJBException,
                         CreateException
Creates a new bean object instance.

If the home belongs to the client container, this method grabs a pooled business object corresponding to this home interface and uses it and the primary key as parameters to a create command. Even when the current thread is involved in a transaction, the effect is to POST the command immediately to the CommandServlet.

If the home belongs to the server container, the key given is checked to make sure it doesn't already exist in the database table corresponding to this home. The record is not created, but a pooled entity bean with the primary key set to the specified value is returned as a new non-pooled entity bean.

Specified by:
create in interface CardHome
Parameters:
cardID - the primary key for the new object.
Returns:
a bean object with the primary key specified.
Throws:
CreateException - if an object with the specified primary key already exists.
EJBException - if the operation fails unexpectedly.

findByPrimaryKey

public CardObject findByPrimaryKey(CardKey cardID)
                            throws EJBException,
                                   FinderException
Finds an existing bean object.

If the home belongs to the client container, this method grabs a pooled business object corresponding to this home interface and uses (1) it and (2) the primary key as parameters to a find command. Even if the current thread is involved in a transaction, the effect is to POST the command immediately to the CommandServlet.

If the home belongs to the server container, a SQL SELECT query is formed to obtain the appropriate record from the database table corresponding to this home. A pooled entity bean is populated with the record data obtained and returned as a new persistent entity bean.

Specified by:
findByPrimaryKey in interface CardHome
Parameters:
cardID - the primary key of the object to be found.
Returns:
the bean object with the primary key specified.
Throws:
FinderException - if an object with the specified primary key does not exist.
EJBException - if the operation fails unexpectedly.

findAllByPrimaryKey

public CardObject findAllByPrimaryKey(CardKey cardID)
                               throws EJBException,
                                      FinderException
Finds an existing bean object, and all its related objects.

If the home belongs to the client container, this method grabs a pooled business object corresponding to this home interface and uses (1) it and (2) the primary key as parameters to a find command. Even if the current thread is involved in a transaction, the effect is to POST the command immediately to the CommandServlet.

If the home belongs to the server container, a SQL SELECT query is formed to obtain the appropriate record from the database table corresponding to this home. A pooled entity bean is populated with the record data obtained and returned as a new persistent entity bean.

Specified by:
findAllByPrimaryKey in interface CardHome
Parameters:
cardID - the primary key of the object to be found.
Returns:
the bean object with the primary key specified.
Throws:
FinderException - if an object with the specified primary key does not exist.
EJBException - if the operation fails unexpectedly.

getFieldNamesForLongestFindWhereFieldsEqual

public Collection getFieldNamesForLongestFindWhereFieldsEqual()
Internal method used by the container to discover the meaning of parameters to the longest findWhereFieldsEqual() method, which is the method used to look up beans with given a foreign key.

Specified by:
getFieldNamesForLongestFindWhereFieldsEqual in interface FieldEqualFinder
Returns:
a collection of field names.

getFieldTypesForLongestFindWhereFieldsEqual

public Class[] getFieldTypesForLongestFindWhereFieldsEqual()
Internal method used by the container to discover the types of parameters for the longest findWhereFieldsEqual() method, which is the method used to look up beans with given a foreign key.

Specified by:
getFieldTypesForLongestFindWhereFieldsEqual in interface FieldEqualFinder
Returns:
the array of types to pass to the longest findWhereFieldsEqual() method.

findAllWhereFieldsEqual

public List findAllWhereFieldsEqual(DeckKey deckID)
                             throws EJBException,
                                    FinderException
Selects many existing bean objects whose fields equal those specified, along with all of their related objects.

If the home belongs to the client container, this method returns a collection of business objects corresponding to this home interface by using (1) a pooled business object from this home along with (2) the constraints on fields listed in the method signature as parameters to a select command. Even if the current thread is involved in a transaction, the effect is to POST the command immediately to the CommandServlet.

If the home belongs to the server container, a SQL SELECT query is formed to obtain a collection of records from the database table corresponding to this home which satisfies the constraints on fields listed in the method signature. Potentially many pooled entity beans are populated with the data obtained and returned as a collection of new persistent entity beans.

Specified by:
findAllWhereFieldsEqual in interface CardHome
Parameters:
deckID - deckID property value to search on, or null if it is not relevant.
Returns:
a collection of matching entity beans.
Throws:
FinderException - never.
EJBException - if the operation fails unexpectedly.

findWhereFieldsEqual

public List findWhereFieldsEqual(DeckKey deckID)
                          throws EJBException,
                                 FinderException
Selects many existing bean objects whose fields equal those specified.

If the home belongs to the client container, this method returns a collection of business objects corresponding to this home interface by using (1) a pooled business object from this home along with (2) the constraints on fields listed in the method signature as parameters to a select command. Even if the current thread is involved in a transaction, the effect is to POST the command immediately to the CommandServlet.

If the home belongs to the server container, a SQL SELECT query is formed to obtain a collection of records from the database table corresponding to this home which satisfies the constraints on fields listed in the method signature. Potentially many pooled entity beans are populated with the data obtained and returned as a collection of new persistent entity beans.

Specified by:
findWhereFieldsEqual in interface CardHome
Parameters:
otherField - otherField property value to search on, or null if it is not relevant.
deckID - deckID property value to search on, or null if it is not relevant.
Returns:
a collection of matching entity beans.
Throws:
FinderException - never.
EJBException - if the operation fails unexpectedly.

remove

public void remove(Object cardID)
            throws EJBException,
                   RemoveException
Removes the bean object with the specified primary key.

If the specified bean belongs to the client container, this method takes the business object corresponding to the specified key and uses it as the parameter to a remove command. If the current thread is not involved in a transaction, the effect is to POST the command immediately to the CommandServlet. The returned version is returned to the pool and the previous version is discarded. If the current thread is involved in a transaction, these actions will only occur when the commit() method of the container is called.

If the specified bean belongs to the server container, a SQL DELETE query is formed to remove the database record corresponding to it. The entity bean is returned. If the current thread is involved in a transaction, the DELETE query will only be executed when the commit() method of the container is called.

Specified by:
remove in interface EJBLocalHome
Parameters:
cardID - the primary key of the object being removed.
Throws:
RemoveException - if objects in this home cannot be removed.
EJBException - if the operation fails- perhaps the object specified doesn't exist.

invokeOnServer

public Object invokeOnServer(Method method,
                             Object[] parameters)
                      throws EJBException

Executes a method of this home interface on the server.

Specified by:
invokeOnServer in interface LocalHome
Parameters:
method - the method to call.
parameters - the parameters to pass to the method.
Returns:
the result of the method call.
Throws:
EJBException - if something goes wrong.

lock

public boolean lock()
             throws EJBException

Locks this home interface on the server, preventing updates until the current transaction commits (or rolls back.)

Specified by:
lock in interface LocalHome
Returns:
true if the lock could be acquired, false otherwise.
Throws:
EJBException - if something goes wrong.