/*
  Copyright (c) 1993-2003 Tumbleweed Communications Corp. All Rights Reserved.
 */
 
//  
//  $Log: $
//
//

package com.tumbleweed.messenger.server.ejb.impl.cmrtest;


import javax.ejb.CreateException;

import org.apache.log4j.Logger;

import com.tumbleweed.messenger.server.util.AbstractEntityBean;

/**
 * Entity Bean representing a Bar (sorry about the naming it's late).
 * Implemented with CMP2.0.
 *
 *   @ejb:bean
 *      name="Bar"
 *      type="CMP"
 *      cmp-version="2.x"
 *      primkey-field="id"
 *      view-type="local"
 *   @ejb:interface
 *      local-class="com.tumbleweed.messenger.server.ejb.api.cmrtest.BarLocal"
 *      local-extends="javax.ejb.EJBLocalObject"
 *   @ejb:home
 *      local-extends="javax.ejb.EJBLocalHome"
 *   @ejb:pk class="java.lang.Long"
 *
 *  findBarsByBarValue()
 *      Just a finder to get Bar's where barValue == someValue
 *
 *   @ejb:finder
 *      signature="Collection findBarsByBarValue(java.lang.String barValue)"
 *      unchecked="true"
 *      query="SELECT OBJECT(b) FROM Bar as b WHERE b.barValue = ?1"
 *      transaction-type="Required"
 *
 * 
 *   @ejb:persistence
 *      table-name="Bar"
 *
 *   @jboss:container-configuration name="Instance Per Transaction CMP 2.x EntityBean"
 *   @jboss:create-table "false"
 *   @jboss:remove-table "false"
 *   @jboss:read-only read-only="false"
 *   @jboss:read-ahead strategy="on-find"
 * 
 *   @jboss:unknown-pk
 *      class="java.lang.Long"
 *      field-name="id"
 *      column-name="id"
 *      readonly="false"
 *      jdbc-type="BIGINT"
 *      sql-type="BIGINT" 
 *      auto-increment
 * 
 *   @jboss:entity-command name="mssql-identity-fetch-key"
 *      class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCSQLServerCreateCommand"
 * 
 */
public abstract class BarEJB extends AbstractEntityBean {
    // -----------------------
    // Members
    // -----------------------

    /**
     * Logger
     */
    private static Logger sLog = Logger.getLogger(BarEJB.class);

    /**
     * Returns the ID for the Bar
     *
     * @return The ID of the Bar.
     *
     * @ejb:interface-method
     *
     * @ejb:persistence
     *   column-name="id"
     */
    public abstract Long getId();

    /**
     *
     * Sets the ID for the Bar.
     *
     * @param barId The ID of the Bar.
     */
    public abstract void setId(Long barId);

    /**
     * Returns the value for the Bar
     *
     * @return The value of the Bar.
     *
     * @ejb:interface-method
     *
     * @ejb:persistence
     *   column-name="barValue"
     */
    public abstract String getBarValue();

    /**
     *
     * Sets the value for the Bar
     *
     * @param barValue the value for the Bar
     */
    public abstract void setBarValue(String barValue);


    /**
     * Gets Foos of this Bar
     *
     * @return foos of this Bar
     *
     * @ejb:interface-method
     * @ejb:relation
     *    name="Bar-Foo"
     *    role-name="1-Bar-N-Foo"
     */
    public abstract java.util.Collection /* FooLocal */ getFoos();

    /**
     * Sets Foos of this Bar
     *
     * @param foos Foos of this Bar
     */
    public abstract void setFoos(java.util.Collection /* FooLocal */ foos);
   
    /**
     * Creates an instance of a Bar.
     *
     * @param barValue the value of this bar.
     * @throws CreateException if the creation fails.
     * @return null to have the application server fill-in primary key (bar ID).
     * 
     * @ejb:create-method
     */
    public Long ejbCreate(String barValue) throws CreateException {
        sLog.debug("ejbCreate(" + barValue + ")");
        setBarValue(barValue);
        return null;
    }

    /**
     * Post-create method that corresponds to {@link #ejbCreate}.
     *
     * @param barValue the value of this bar.
     * @throws CreateException if the creation fails.
     */
    public void ejbPostCreate(String barValue) throws CreateException {
        sLog.debug("ejbPostCreate(" + getId() + ")");
    }

}
