package address.ejb;

/**
 * @ejb.bean
 *    type="CMP"
 *    cmp-version="2.x"
 *    name="Address"
 *    local-jndi-name="addressbook/ejb/AddressLocalHome"
 *    jndi-name="addressbook/ejb/AddressHome"
 *    view-type="both"
 *    primkey-field="addressId"
 *
 * @ejb.finder
 *    signature="java.util.Collection findAll()"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT OBJECT(o) FROM Address o"
 *
 * @ejb.finder
 *    signature="java.util.Collection findByStreet(java.lang.String street)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Address o WHERE o.street = ?1"
 *    description="street is not indexed."
 *
 * @ejb.finder
 *    signature="java.util.Collection findByCity(java.lang.String city)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Address o WHERE o.city = ?1"
 *    description="city is not indexed."
 *
 * @ejb.finder
 *    signature="java.util.Collection findByState(java.lang.String state)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Address o WHERE o.state = ?1"
 *    description="state is not indexed."
 *
 * @ejb.finder
 *    signature="java.util.Collection findByZipCode(java.lang.String zipCode)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Address o WHERE o.zipCode = ?1"
 *    description="zip_code is not indexed."
 *
 * @ejb.persistence table-name="address"
 *
 * @weblogic.data-source-name address.database
 */
public abstract class AddressBean implements javax.ejb.EntityBean {

	/**
	 * Returns the addressId
	 * @todo support OracleClob,OracleBlob on WLS
	 *
	 * @return the addressId
	 *
	 * @ejb.pk-field
	 * @ejb.interface-method view-type="both"
	 * @ejb.persistence column-name="address_id"
	 */
	public abstract java.lang.Integer getAddressId();

	/**
	 * Sets the addressId
	 *
	 * @param java.lang.Integer the new addressId value
	 * @ejb.interface-method view-type="both"
	 */
	public abstract void setAddressId(java.lang.Integer addressId);

	/**
	 * Returns the street
	 * @todo support OracleClob,OracleBlob on WLS
	 *
	 * @return the street
	 *
	 * @ejb.interface-method view-type="both"
	 * @ejb.persistence column-name="street"
	 */
	public abstract java.lang.String getStreet();

	/**
	 * Sets the street
	 *
	 * @param java.lang.String the new street value
	 * @ejb.interface-method view-type="both"
	 */
	public abstract void setStreet(java.lang.String street);

	/**
	 * Returns the city
	 * @todo support OracleClob,OracleBlob on WLS
	 *
	 * @return the city
	 *
	 * @ejb.interface-method view-type="both"
	 * @ejb.persistence column-name="city"
	 */
	public abstract java.lang.String getCity();

	/**
	 * Sets the city
	 *
	 * @param java.lang.String the new city value
	 * @ejb.interface-method view-type="both"
	 */
	public abstract void setCity(java.lang.String city);

	/**
	 * Returns the state
	 * @todo support OracleClob,OracleBlob on WLS
	 *
	 * @return the state
	 *
	 * @ejb.interface-method view-type="both"
	 * @ejb.persistence column-name="state"
	 */
	public abstract java.lang.String getState();

	/**
	 * Sets the state
	 *
	 * @param java.lang.String the new state value
	 * @ejb.interface-method view-type="both"
	 */
	public abstract void setState(java.lang.String state);

	/**
	 * Returns the zipCode
	 * @todo support OracleClob,OracleBlob on WLS
	 *
	 * @return the zipCode
	 *
	 * @ejb.interface-method view-type="both"
	 * @ejb.persistence column-name="zip_code"
	 */
	public abstract java.lang.String getZipCode();

	/**
	 * Sets the zipCode
	 *
	 * @param java.lang.String the new zipCode value
	 * @ejb.interface-method view-type="both"
	 */
	public abstract void setZipCode(java.lang.String zipCode);

	/**
	 * This is a bi-directional one-to-one relationship CMR method
	 *
	 * @return the related address.interfaces.PersonLocal.
	 *
	 * @ejb.interface-method view-type="local"
	 *
	 * @ejb.relation
	 *    name="address-cmp20-person-cmp20"
	 *    role-name="address-cmp20-has-person-cmp20"
	 *
	 * @jboss.relation-mapping style="foreign-key"
	 *
	 */
	public abstract address.ejb.PersonLocal getPerson();

	/**
	 * Sets the related address.interfaces.PersonLocal
	 *
	 * @param address.interfaces.AddressLocal the related $target.variableName
	 *
	 * @ejb.interface-method view-type="local"
	 *
	 * @param person the new CMR value
	 */
	public abstract void setPerson(address.ejb.PersonLocal person);

	/**
	 * This create method takes only mandatory (non-nullable) parameters.
	 *
	 * When the client invokes a create method, the EJB container invokes the ejbCreate method. 
	 * Typically, an ejbCreate method in an entity bean performs the following tasks: 
	 * <UL>
	 * <LI>Inserts the entity state into the database.</LI>
	 * <LI>Initializes the instance variables.</LI>
	 * <LI>Returns the primary key.</LI>
	 * </UL>
	 *
	 * @return the primary key of the new instance
	 *
	 * @ejb.create-method
	 */
	public java.lang.Integer ejbCreate() throws javax.ejb.CreateException {
		// Use XDoclet's GUID generator. Only works for String fields
		// This requires <utilobject includeGUID="true"/> in ejbdoclet.

		// Set CMP fields
		// EJB 2.0 spec says return null for CMP ejbCreate methods.
		this.setAddressId(generatePrimaryKey());
		return null;
	}

	/**
	 * The container invokes thos method immediately after it calls ejbCreate. 
	 *
	 */
	public void ejbPostCreate() throws javax.ejb.CreateException {
		// Set CMR fields
	}

	/**
	 * This create method takes all parameters (both nullable and not nullable). 
	 *
	 * When the client invokes a create method, the EJB container invokes the ejbCreate method. 
	 * Typically, an ejbCreate method in an entity bean performs the following tasks: 
	 * <UL>
	 * <LI>Inserts the entity state into the database.</LI>
	 * <LI>Initializes the instance variables.</LI>
	 * <LI>Returns the primary key.</LI>
	 * </UL>
	 *
	 * @param street the street value
	 * @param city the city value
	 * @param state the state value
	 * @param zipCode the zipCode value
	 * @param person CMR field
	 * @return the primary key of the new instance
	 *
	 * @ejb.create-method
	 */
	public java.lang.Integer ejbCreate(
		java.lang.String street,
		java.lang.String city,
		java.lang.String state,
		java.lang.String zipCode,
		address.ejb.PersonLocal person)
		throws javax.ejb.CreateException {
		// Use XDoclet's GUID generator. Only works for String fields
		// This requires <utilobject includeGUID="true"/> in ejbdoclet.

		setAddressId(generatePrimaryKey());
		// Set CMP fields
		setStreet(street);
		setCity(city);
		setState(state);
		setZipCode(zipCode);
		// EJB 2.0 spec says return null for CMP ejbCreate methods.
		return null;
	}

	/**
	 * The container invokes thos method immediately after it calls ejbCreate. 
	 *
	 * @param street the street value
	 * @param city the city value
	 * @param state the state value
	 * @param zipCode the zipCode value
	 * @param person CMR field
	 */
	public void ejbPostCreate(
		java.lang.String street,
		java.lang.String city,
		java.lang.String state,
		java.lang.String zipCode,
		address.ejb.PersonLocal person)
		throws javax.ejb.CreateException {
		// Set CMR fields
		setPerson(person);
	}

	public java.lang.Integer generatePrimaryKey() {
		return new Integer(this.hashCode());
	}
}
