ItemBean.java
资源名称:MyStore.rar [点击查看]
上传用户:hgs128
上传日期:2007-02-03
资源大小:166k
文件大小:6k
源码类别:
百货/超市行业
开发平台:
WINDOWS
- /*
- * Created on 1999-5-18
- */
- package cmp;
- import javax.ejb.EntityBean;
- import javax.ejb.EntityContext;
- /**
- * @ejb.bean name="Item"
- * jndi-name="ItemBean"
- * type="CMP"
- * primkey-field="itemID"
- * schema="mySchema"
- * cmp-version="2.x"
- *
- *--
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.bean ejb-name="Item"
- * jndi-name="ItemBean"
- * @jonas.jdbc-mapping jndi-name="java:/OracleDS" jdbc-table-name="Items"
- * --
- *
- * @ejb.persistence
- * table-name="Items"
- *
- * @ejb.finder
- * query="SELECT OBJECT(a) FROM mySchema as a"
- * signature="java.util.Collection findAll()"
- *
- * @ejb.finder
- * query="SELECT OBJECT(b) FROM mySchema b where b.supplierID=?1"
- * signature="java.util.Collection findBySupplierID(java.lang.String supplierID)"
- *
- * @ejb.finder
- * query="SELECT OBJECT(c) FROM mySchema c where c.quantity=0"
- * signature="java.util.Collection findByOutOfStock()"
- *--
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.finder-method-jdbc-mapping method-name="findAll"
- * jdbc-where-clause=""
- * @jonas.jdbc-mapping jndi-name="java:/OracleDS"
- * jdbc-table-name="Items"
- *
- *--
- *
- **/
- public abstract class ItemBean implements EntityBean {
- protected EntityContext eContext;
- public void setEntityContext(EntityContext context) {
- eContext=context;
- }
- public void unsetEntityContext() {
- eContext=null;
- }
- /**
- * The ejbCreate method.
- *
- * @ejb.create-method
- */
- public java.lang.String ejbCreate(String itemID,String supplierID,String description,
- Integer quantity,Float price) throws javax.ejb.CreateException {
- // EJB 2.0 spec says return null for CMP ejbCreate methods.
- // TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
- // setMyField("Something");
- System.out.println("Entering ItemBean,ejbCreate()");
- setItemID(itemID);
- setSupplierID(supplierID);
- setDescription(description);
- setQuantity(quantity);
- setPrice(price);
- System.out.println("Leaving ItemBean.ejbCreate()");
- return null;
- }
- /**
- * The container invokes this method immediately after it calls ejbCreate.
- *
- */
- public void ejbPostCreate() throws javax.ejb.CreateException {
- }
- /**
- * Returns the ItemID
- * @return the ItemID
- *
- * @ejb.persistent-field
- * @ejb.persistence
- * column-name="ItemID"
- * sql-type="varchar2"
- * @ejb.pk-field
- * @ejb.interface-method
- *
- * --
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.cmp-field-jdbc-mapping field-name="ItemID"
- * jdbc-field-name="ItemID"
- *
- --
- */
- public abstract java.lang.String getItemID();
- /**
- * Sets the ItemID
- *
- * @param java.lang.String the new ItemID value
- *
- * @ejb.interface-method
- */
- public abstract void setItemID(java.lang.String ItemID);
- /**
- * Returns the SupplierID
- * @return the SupplierID
- *
- * @ejb.persistent-field
- * @ejb.persistence
- * column-name="SupplierID"
- * sql-type="varchar2"
- *
- * @ejb.interface-method
- *
- * --
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.cmp-field-jdbc-mapping field-name="SupplierID"
- * jdbc-field-name="SupplierID"
- *
- --
- */
- public abstract java.lang.String getSupplierID();
- /**
- * Sets the SupplierID
- *
- * @param java.lang.String the new SupplierID value
- *
- * @ejb.interface-method
- */
- public abstract void setSupplierID(java.lang.String SupplierID);
- /**
- * Returns the Description
- * @return the Description
- *
- * @ejb.persistent-field
- * @ejb.persistence
- * column-name="Description"
- * sql-type="varchar2"
- *
- * @ejb.interface-method
- *
- * --
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.cmp-field-jdbc-mapping field-name="Description"
- * jdbc-field-name="Description"
- *
- --
- */
- public abstract java.lang.String getDescription();
- /**
- * Sets the Description
- *
- * @param java.lang.String the new Description value
- *
- * @ejb.interface-method
- */
- public abstract void setDescription(java.lang.String Description);
- /**
- * Returns the Quantity
- * @return the Quantity
- *
- * @ejb.persistent-field
- * @ejb.persistence
- * column-name="Quantity"
- * sql-type="INTEGER"
- *
- * @ejb.interface-method
- *
- * --
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.cmp-field-jdbc-mapping field-name="Quantity"
- * jdbc-field-name="Quantity"
- *
- --
- */
- public abstract java.lang.Integer getQuantity();
- /**
- * Sets the Quantity
- *
- * @param java.lang.Integer the new Quantity value
- *
- * @ejb.interface-method
- */
- public abstract void setQuantity(java.lang.Integer Quantity);
- /**
- * Returns the Price
- * @return the Price
- *
- * @ejb.persistent-field
- * @ejb.persistence
- * column-name="Price"
- * sql-type="DECIMAL"
- *
- * @ejb.interface-method
- *
- * --
- * This is needed for JOnAS.
- * If you are not using JOnAS you can safely remove the tags below.
- * @jonas.cmp-field-jdbc-mapping field-name="Price"
- * jdbc-field-name="Price"
- *
- --
- */
- public abstract java.lang.Float getPrice();
- /**
- * Sets the Price
- *
- * @param java.lang.Float the new Price value
- *
- * @ejb.interface-method
- */
- public abstract void setPrice(java.lang.Float Price);
- /** * @ejb.interface-method * view-type="local" **/ public ItemData getItemData(){
- System.out.println("Entering ItemBean.getItemData()");
- System.out.println("Leaving ItemBean.getItemData()"); return new ItemData(getItemID(),getSupplierID(),getDescription(),
- getQuantity(),getPrice()); }
- /** * @ejb.interface-method * view-type="local" **/ public void fillStock (Integer quantity){
- System.out.println("Entering ItemBean.fillStock()");
- Integer qty=new Integer(quantity.intValue()+getQuantity().intValue());
- System.out.println("Quantity of items delivery of items"+qty.intValue());
- setQuantity(qty);
- System.out.println("Leaving ItemBean.fillStock()"); } }