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 "bean 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()
          Mandatory methods
 BuyNowPK ejbCreate(java.lang.Integer BuyNowUserId, java.lang.Integer BuyNowItemId, int quantity)
          This method is used to create a new BuyNow Bean.
 java.util.Collection ejbFindAllBuyNows()
          This method is used to retrieve all BuyNows from the database!
 java.util.Collection ejbFindByItem(java.lang.Integer id)
          This method is used to retrieve all BuyNow Beans related to one item.
 BuyNowPK ejbFindByPrimaryKey(BuyNowPK id)
          This method is used to retrieve a BuyNow Bean from its primary key, that is to say its id.
 java.util.Collection ejbFindByUser(java.lang.Integer id)
          This method is used to retrieve all BuyNow Beans belonging to a specific user.
 java.util.Collection ejbFindUserBuyNow(java.lang.Integer userId)
          Get all the items the user bought using the buy-now option in the last 30 days.
 void ejbLoad()
          Read the reccord from the database and update the bean.
 void ejbPassivate()
           
 void ejbPostCreate(java.lang.Integer BuyNowUserId, java.lang.Integer BuyNowItemId, int quantity)
          This method does currently nothing
 void ejbRemove()
          This method delete the record from the database.
 void ejbStore()
          Update the record.
 java.lang.Integer getBuyerId()
          Get the buyer id which is the primary key in the users table.
 java.sql.Connection getConnection()
          Retrieve a connection..
 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.
 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

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
Retrieve a connection..
Returns:
connection
Throws:
java.lang.Exception - if an error occurs

ejbFindByPrimaryKey

public BuyNowPK ejbFindByPrimaryKey(BuyNowPK id)
                             throws javax.ejb.FinderException,
                                    java.rmi.RemoteException
This method is used to retrieve a BuyNow Bean from its primary key, that is to say its id.
Parameters:
id - BuyNow id (primary key)
Returns:
the BuyNow if found else null
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindByItem

public java.util.Collection ejbFindByItem(java.lang.Integer id)
                                   throws javax.ejb.FinderException,
                                          java.rmi.RemoteException
This method is used to retrieve all BuyNow Beans related to one item. You must provide the item id.
Parameters:
id - item id
Returns:
List of BuyNows found (eventually empty)
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindByUser

public java.util.Collection ejbFindByUser(java.lang.Integer id)
                                   throws javax.ejb.FinderException,
                                          java.rmi.RemoteException
This method is used to retrieve all BuyNow Beans belonging to a specific user. You must provide the user id.
Parameters:
id - user id
Returns:
List of BuyNows found (eventually empty)
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindAllBuyNows

public java.util.Collection ejbFindAllBuyNows()
                                       throws java.rmi.RemoteException,
                                              javax.ejb.FinderException
This method is used to retrieve all BuyNows from the database!
Returns:
List of all BuyNows (eventually empty)
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.FinderException - if an error occurs

ejbFindUserBuyNow

public java.util.Collection ejbFindUserBuyNow(java.lang.Integer userId)
                                       throws java.rmi.RemoteException,
                                              javax.ejb.FinderException
Get all the items the user bought using the buy-now option in the last 30 days.
Parameters:
userId - user id
Returns:
Collection of items primary keys (can be less than maxToCollect)
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.FinderException - 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
Mandatory methods
Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Specified by:
ejbPassivate in interface javax.ejb.EntityBean

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
This method delete the record from the database.
Specified by:
ejbRemove in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.RemoveException - if an error occurs

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Update the record.
Specified by:
ejbStore in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Read the reccord from the database and update the bean.
Specified by:
ejbLoad in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs

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.

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.