edu.rice.rubis.beans
Class BuyNowBean

java.lang.Object
  |
  +--edu.rice.rubis.beans.BuyNowBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.EntityBean, java.io.Serializable

public class BuyNowBean
extends java.lang.Object
implements javax.ejb.EntityBean

BuyNowBean is an entity bean with "container managed persistence". The state of an instance is stored into a relational database. The following table should exist:

 CREATE TABLE buy_now (
   id       INTEGER UNSIGNED NOT NULL UNIQUE,
   buyer_id INTEGER UNSIGNED NOT NULL,
   item_id  INTEGER UNSIGNED NOT NULL,
   qty      INTEGER,
   date     DATETIME,
   PRIMARY KEY(id),
   INDEX buyer (buyer_id),
   INDEX item (item_id)
 );
 

Version:
1.0
Author:
Emmanuel Cecchet and Julie Marguerite
See Also:
Serialized Form

Field Summary
 java.lang.Integer buyerId
           
 java.lang.String date
           
 java.lang.Integer id
           
 java.lang.Integer itemId
           
 int qty
           
 
Constructor Summary
BuyNowBean()
           
 
Method Summary
 void ejbActivate()
          This method is empty because persistence is managed by the container
 BuyNowPK ejbCreate(java.lang.Integer BuyNowUserId, java.lang.Integer BuyNowItemId, int quantity)
          This method is used to create a new BuyNow Bean.
 void ejbLoad()
          Persistence is managed by the container and the bean becomes up to date
 void ejbPassivate()
          This method is empty because persistence is managed by the container
 void ejbPostCreate(java.lang.Integer BuyNowUserId, java.lang.Integer BuyNowItemId, int quantity)
          This method does currently nothing
 void ejbRemove()
          This method is empty because persistence is managed by the container
 void ejbStore()
          Persistence is managed by the container and the bean becomes up to date
 java.lang.Integer getBuyerId()
          Get the buyer id which is the primary key in the users table.
 java.lang.String getDate()
          Time of the BuyNow in the format 'YYYY-MM-DD hh:mm:ss'
 java.lang.Integer getId()
          Get BuyNow id.
 java.lang.Integer getItemId()
          Get the item id which is the primary key in the items table.
 int getQuantity()
          Get how many of this item the user has bought.
 boolean isModified()
          Returns true if the beans has been modified.
 void setBuyerId(java.lang.Integer id)
          Set a new buyer identifier.
 void setDate(java.lang.String newDate)
          Set a new date for this BuyNow
 void setEntityContext(javax.ejb.EntityContext context)
          Sets the associated entity context.
 void setItemId(java.lang.Integer id)
          Set a new item identifier.
 void setQuantity(int Qty)
          Set a new quantity for this BuyNow
 void unsetEntityContext()
          Unsets the associated entity context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public java.lang.Integer id

buyerId

public java.lang.Integer buyerId

itemId

public java.lang.Integer itemId

qty

public int qty

date

public java.lang.String date
Constructor Detail

BuyNowBean

public BuyNowBean()
Method Detail

getId

public java.lang.Integer getId()
                        throws java.rmi.RemoteException
Get BuyNow id.
Returns:
BuyNow id
Throws:
java.rmi.RemoteException - if an error occurs

getBuyerId

public java.lang.Integer getBuyerId()
                             throws java.rmi.RemoteException
Get the buyer id which is the primary key in the users table.
Returns:
user id
Throws:
java.rmi.RemoteException - if an error occurs

getItemId

public java.lang.Integer getItemId()
                            throws java.rmi.RemoteException
Get the item id which is the primary key in the items table.
Returns:
item id
Throws:
java.rmi.RemoteException - if an error occurs

getQuantity

public int getQuantity()
                throws java.rmi.RemoteException
Get how many of this item the user has bought.
Returns:
quantity of items for this BuyNow.
Throws:
java.rmi.RemoteException - if an error occurs

getDate

public java.lang.String getDate()
                         throws java.rmi.RemoteException
Time of the BuyNow in the format 'YYYY-MM-DD hh:mm:ss'
Returns:
BuyNow time
Throws:
java.rmi.RemoteException - if an error occurs

setBuyerId

public void setBuyerId(java.lang.Integer id)
                throws java.rmi.RemoteException
Set a new buyer identifier. This id must match the primary key of the users table.
Parameters:
id - buyer id
Throws:
java.rmi.RemoteException - if an error occurs

setItemId

public void setItemId(java.lang.Integer id)
               throws java.rmi.RemoteException
Set a new item identifier. This id must match the primary key of the items table.
Parameters:
id - item id
Throws:
java.rmi.RemoteException - if an error occurs

setQuantity

public void setQuantity(int Qty)
                 throws java.rmi.RemoteException
Set a new quantity for this BuyNow
Parameters:
Qty - quantity
Throws:
java.rmi.RemoteException - if an error occurs

setDate

public void setDate(java.lang.String newDate)
             throws java.rmi.RemoteException
Set a new date for this BuyNow
Parameters:
newDate - BuyNow date
Throws:
java.rmi.RemoteException - if an error occurs

ejbCreate

public BuyNowPK ejbCreate(java.lang.Integer BuyNowUserId,
                          java.lang.Integer BuyNowItemId,
                          int quantity)
                   throws javax.ejb.CreateException,
                          java.rmi.RemoteException,
                          javax.ejb.RemoveException
This method is used to create a new BuyNow Bean. The date is automatically set to the current date when the method is called.
Parameters:
BuyNowUserId - user id of the buyer, must match the primary key of table users
BuyNowItemId - item id, must match the primary key of table items
quantity - number of items the user wants to buy
Returns:
pk primary key set to null
Throws:
javax.ejb.CreateException - if an error occurs
java.rmi.RemoteException - if an error occurs
javax.ejb.RemoveException - if an error occurs

ejbPostCreate

public void ejbPostCreate(java.lang.Integer BuyNowUserId,
                          java.lang.Integer BuyNowItemId,
                          int quantity)
This method does currently nothing

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
This method is empty because persistence is managed by the container
Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
This method is empty because persistence is managed by the container
Specified by:
ejbPassivate in interface javax.ejb.EntityBean

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
This method is empty because persistence is managed by the container
Specified by:
ejbRemove in interface javax.ejb.EntityBean

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Persistence is managed by the container and the bean becomes up to date
Specified by:
ejbStore in interface javax.ejb.EntityBean

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Persistence is managed by the container and the bean becomes up to date
Specified by:
ejbLoad in interface javax.ejb.EntityBean

setEntityContext

public void setEntityContext(javax.ejb.EntityContext context)
                      throws java.rmi.RemoteException
Sets the associated entity context. The container invokes this method on an instance after the instance has been created. This method is called in an unspecified transaction context.
Specified by:
setEntityContext in interface javax.ejb.EntityBean
Parameters:
context - An EntityContext interface for the instance. The instance should store the reference to the context in an instance variable.
Throws:
javax.ejb.EJBException - Thrown by the method to indicate a failure caused by a system-level error.
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specification should throw the javax.ejb.EJBException instead of this exception.

isModified

public boolean isModified()
Returns true if the beans has been modified. It prevents the EJB server from reloading a bean that has not been modified.
Returns:
a boolean value

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Unsets the associated entity context. The container calls this method before removing the instance. This is the last method that the container invokes on the instance. The Java garbage collector will eventually invoke the finalize() method on the instance. This method is called in an unspecified transaction context.
Specified by:
unsetEntityContext in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Thrown by the method to indicate a failure caused by a system-level error.
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specification should throw the javax.ejb.EJBException instead of this exception.


Copyright © 2003 - ObjectWeb Consortium - All Rights Reserved.