package com.alodar.example.ejb;

/**
 * @author Mark Lui
 *
 * @ejb:bean
 *    type="CMP"
 *    cmp-version="2.x"
 *    name="Item"
 *    jndi-name="com.alodar.example.interfaces.Item"
 *    local-jndi-name="com.alodar.example.interfaces.ItemLocal"
 *    view-type="both"
 *
 * @ejb:util
 *      generate="physical"
 *
 * @jboss:table-name Item
 * @jboss:create-table "false"
 *
 * @jboss-net:data-object
 *      urn="ItemData"
 */
public abstract class ItemBean implements javax.ejb.EntityBean
{

    /**
    * Context set by container
    */
    private javax.ejb.EntityContext _entityContext;

    
    /**
    * Returns the itemId
    *
    * @return the itemId
    *
    * @ejb:persistent-field
    * @ejb:pk-field
    *
    * @jboss:column-name ItemId
    */
    public abstract Integer getItemId();

    /**
    * Sets the itemId
    *
    * @param itemId the new itemId
    */
    public abstract void setItemId(Integer itemId);
    
    /**
    * Returns the description
    *
    * @return the description
    *
    * @ejb:persistent-field
    * 
    *
    * @jboss:column-name Description
    */
    public abstract String getDescription();

    /**
    * Sets the description
    *
    * @param description the new description
    */
    public abstract void setDescription(String description);
    
    
    /**
     * Returns a local Customer
     *
     * @return a local Customer
     *
     * @ejb:interface-method view-type="local"
     *
     * @ejb:relation
     *    name="Customer-Item"
     *    role-name="Item-has-Customer"
     *
     * @jboss:relation
     *      fk-constraint = "true"
     *      fk-column = "CustomerId"
     *      related-pk-field = "customerId"
     */
    public abstract com.alodar.example.interfaces.CustomerLocal getCustomer();

    /**
     * Sets a local Customer
     *
     * @param languageCode a local Customer
     *
     * @ejb:interface-method view-type="local"
     */
    public abstract void setCustomer(com.alodar.example.interfaces.CustomerLocal customer);
    
    /**
    * Gets a data object representing this instance
    *
    * @return a data object representing this instance
    *
    * @ejb:interface-method view-type="both"
    */
    public com.alodar.example.interfaces.ItemData getData()
    {
      // We don't implement it here. XDoclet will create a subclass that implements it properly.
      return null;
    }

    /**
    * Sets a data object representing this instance
    *
    * @param data a data object holding new values
    *
    * @ejb:interface-method view-type="both"
    */
    public void setData(com.alodar.example.interfaces.ItemData data)
    {
      // We don't implement it here. XDoclet will create a subclass that implements it properly.
    }

    /**
    * 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:
    *
    * Inserts the entity state into the database.
    * Initializes the instance variables.
    * Returns the primary key.
    *
    *
    * @param data the data object used to initialise the new instance
    * @return the primary key of the new instance
    *
    * @ejb:create-method
    */
    public com.alodar.example.interfaces.ItemPK ejbCreate(com.alodar.example.interfaces.ItemData data) throws javax.ejb.CreateException
    {
      setItemId(data.getItemId());
      setData(data);
      // EJB 2.0 spec says return null for CMP ejbCreate methods.
      return null;
    }

    /**
    * The container invokes thos method immediately after it calls ejbCreate.
    *
    * @param data the data object used to initialise the new instance
    */
    public void ejbPostCreate(com.alodar.example.interfaces.ItemData data) throws javax.ejb.CreateException
    {
    }

    // Implementation of the javax.ejb.EntityBean interface methods

    /**
    * The container invokes setEntityContext just once - when it creates the bean instance.
    */
    public void setEntityContext(javax.ejb.EntityContext entityContext)
    {
      _entityContext = entityContext;
    }

    /**
    * At the end of the life cycle, the container removes the instance from
    * the pool and invokes this method.
    */
    public void unsetEntityContext()
    {
      _entityContext = null;
    }

    /**
    * The container invokes this method to instruct the instance to synchronize its
    * state by loading it state from the underlying database.
    */
    public void ejbLoad()
    {
    }

    /**
    * The container invokes this method when the instance is taken out of the pool of
    * available instances to become associated with a specific EJB object.
    */
    public void ejbActivate()
    {
    }

    /**
    * The container invokes this method on an instance before the instance becomes
    * disassociated with a specific EJB object.
    */
    public void ejbPassivate()
    {
    }

    /**
    * The container invokes this method before it removes the EJB object that is
    * currently associated with the instance.
    */
    public void ejbRemove() throws javax.ejb.RemoveException
    {
    }

    /**
    * The container invokes this method to instruct the instance to synchronize its
    * state by storing it to the underlying database.
    */
    public void ejbStore()
    {
    }
}