package airline.ejb;

/**
 * This class is part of Middlegen airlines, and it is
 * a CMP EJB accessing the FLIGHTS table.
 *
 * @author <a href="http://boss.bekk.no/boss/middlegen/">Middlegen</a>
 * @todo generate create methods which don't take pk as arg (and use an arbitrary pk generator internally)
 *
 *
 * @ejb.bean
 *    type="CMP"
 *    cmp-version="2.x"
 *    name="Flight"
 *    local-jndi-name="airline.FlightLocalHome"
 *    view-type="local"
 *    primkey-field="flightId"
 *
 * @ejb.finder
 *    signature="java.util.Collection findAll()"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT OBJECT(o) FROM Flight o"
 *
 * @ejb.finder
 *    signature="java.util.Collection findByName(java.lang.String name)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Flight o WHERE o.name = ?1"
 *    description="NAME is not indexed."
 *
 * @ejb.finder
 *    signature="java.util.Collection findByDepartureUtc(java.sql.Timestamp departureUtc)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Flight o WHERE o.departureUtc = ?1"
 *    description="DEPARTURE_UTC is not indexed."
 *
 * @ejb.finder
 *    signature="java.util.Collection findByArrivalUtc(java.sql.Timestamp arrivalUtc)"
 *    result-type-mapping="Local"
 *    method-intf="LocalHome"
 *    query="SELECT DISTINCT OBJECT(o) FROM Flight o WHERE o.arrivalUtc = ?1"
 *    description="ARRIVAL_UTC is not indexed."
 *
 * @ejb.persistence table-name="FLIGHTS"
 *
 * @weblogic.data-source-name airline.database
 */
public abstract class FlightBean implements javax.ejb.EntityBean {

   /**
    * Returns the flightId
    * @todo support OracleClob,OracleBlob on WLS
    *
    * @return the flightId
    *
    * @ejb.pk-field
    * @ejb.interface-method view-type="local"
    * @ejb.persistence column-name="FLIGHT_ID"
    */
   public abstract java.lang.Integer getFlightId();

   /**
    * Sets the flightId
    *
    * @param java.lang.Integer the new flightId value
    */
   public abstract void setFlightId(java.lang.Integer flightId);

   /**
    * Returns the name
    * @todo support OracleClob,OracleBlob on WLS
    *
    * @return the name
    *
    * @ejb.interface-method view-type="local"
    * @ejb.persistence column-name="NAME"
    */
   public abstract java.lang.String getName();

   /**
    * Sets the name
    *
    * @param java.lang.String the new name value
    * @ejb.interface-method view-type="local"
    * @ejb:transaction type="Never"
    */
   public abstract void setName(java.lang.String name);

   /**
    * Returns the departureUtc
    * @todo support OracleClob,OracleBlob on WLS
    *
    * @return the departureUtc
    *
    * @ejb.interface-method view-type="local"
    * @ejb.persistence column-name="DEPARTURE_UTC"
    */
   public abstract java.sql.Timestamp getDepartureUtc();

   /**
    * Sets the departureUtc
    *
    * @param java.sql.Timestamp the new departureUtc value
    * @ejb.interface-method view-type="local"
    */
   public abstract void setDepartureUtc(java.sql.Timestamp departureUtc);

   /**
    * Returns the arrivalUtc
    * @todo support OracleClob,OracleBlob on WLS
    *
    * @return the arrivalUtc
    *
    * @ejb.interface-method view-type="local"
    * @ejb.persistence column-name="ARRIVAL_UTC"
    */
   public abstract java.sql.Timestamp getArrivalUtc();

   /**
    * Sets the arrivalUtc
    *
    * @param java.sql.Timestamp the new arrivalUtc value
    * @ejb.interface-method view-type="local"
    */
   public abstract void setArrivalUtc(java.sql.Timestamp arrivalUtc);

   /**
    * This is a bi-directional one-to-many relationship CMR method
    *
    * @return a java.util.Collection of related airline.interfaces.ReservationLocal.
    * middlegen.plugins.entitybean.Entity20Table@491c4c
    * class middlegen.plugins.entitybean.Entity20Table
    * middlegen.plugins.entitybean.Entity20Table
    * @ejb.interface-method view-type="local"
    *
    * @ejb.relation
    *    name="FLIGHTS-cmp20-RESERVATIONS-cmp20"
    *    role-name="FLIGHTS-cmp20-has-RESERVATIONS-cmp20"
    *
    * @jboss.relation-mapping style="foreign-key"
    *
    */
   public abstract java.util.Collection getReservations();

   /**
    * Sets a collection of related airline.interfaces.ReservationLocal
    *
    * @param a collection of related airline.interfaces.ReservationLocal
    *
    * @ejb.interface-method view-type="local"
    *
    * @param reservations the new CMR value
    */
   public abstract void setReservations(java.util.Collection reservations);

   /**
    * This create method takes only mandatory (non-nullable) parameters. The pk columns must be provided.
    *
    * 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 flightId the flightId value
    * @param name the name value
    * @param departureUtc the departureUtc value
    * @param arrivalUtc the arrivalUtc value
    * @return the primary key of the new instance
    *
    * @ejb.create-method
    */
   public java.lang.Integer ejbCreate( java.lang.Integer flightId, java.lang.String name, java.sql.Timestamp departureUtc, java.sql.Timestamp arrivalUtc ) throws javax.ejb.CreateException {
      setFlightId(flightId);
      setName(name);
      setDepartureUtc(departureUtc);
      setArrivalUtc(arrivalUtc);
      // EJB 2.0 spec says return null for CMP ejbCreate methods.
      return null;
   }

   /**
    * The container invokes thos method immediately after it calls ejbCreate. 
    *
    * @param flightId the flightId value
    * @param name the name value
    * @param departureUtc the departureUtc value
    * @param arrivalUtc the arrivalUtc value
    */
   public void ejbPostCreate( java.lang.Integer flightId, java.lang.String name, java.sql.Timestamp departureUtc, java.sql.Timestamp arrivalUtc ) throws javax.ejb.CreateException {
      // Set CMR fields
   }

     
   // Merged code
   /**
    * @ejb.interface-method view-type="local"
    */
   public java.util.Collection getReservationsBefore(java.util.Date date, airline.interfaces.FlightLocal flight) throws javax.ejb.FinderException {
      return ejbSelectReservationsBefore(date, flight);
   }

   /**
    * @ejb.select
    *    query="
    *       SELECT DISTINCT OBJECT(reservation) 
    *       FROM Flight flight, IN(flight.reservations) reservation
    *       WHERE reservation.registrationUtc = ?1 AND flight = ?2
    *    "
    *    result-type-mapping="Local"
    */
   public abstract java.util.Collection ejbSelectReservationsBefore(java.util.Date date, airline.interfaces.FlightLocal flight)
      throws javax.ejb.FinderException;
   
}
