eclipse+lomboz+jboss开发疑问(新手)

03-10-23 wzbbuaa
大家好。开发cmp中遇到问题

我用lomboz向导生成的bean后在增加方法(add method)中怎么

没有

finder方法,是不是需要手动添加???

好像只有home和create方法!

anonymous
2003-10-23 14:30
不会的话,问我好了。

先指点一下:搞懂lomboz, 必须搞清楚 ant & Xdoclet这两个工具。

以下是一个 cmp 示例:

/*

* Created on 2003-10-10

*/

package au.com.tusc.cmp;

import javax.ejb.EntityBean;

import javax.ejb.EntityContext;

/**

@ejb.bean name="Item"

view-type="local"

jndi-name="ItemBean"

type="CMP"

primkey-field="itemID"

schema="MyStoreItem"

cmp-version="2.x"

@ejb.persistence

table-name="item"

@ejb.finder

query="SELECT OBJECT(a) FROM MyStoreItem as a"

signature="java.util.Collection findAll()"

@ejb.finder

query="SELECT OBJECT(a) FROM MyStoreItem as a where a.supplierID = ?1"

signature="java.util.Collection findBySupplierID(java.lang.String supplierID)"

@ejb.finder

query="SELECT OBJECT(c) FROM MyStoreItem as c where c.quantity = 0"

signature="java.util.Collection findByOutOfStock()"

@ejb.value-object

@ejb.util generate = "physical"

**/

public abstract class ItemBean implements EntityBean {

protected EntityContext ctx;

public void setEntityContext(EntityContext ctx) {

this.ctx = ctx;

}

public void unsetEntityContext(EntityContext ctx) {

this.ctx = null;

}

/**

* @ejb.create-method

*/

public java.lang.String ejbCreate(

String itemID,

String supplierID,

String desc,

Integer quanlity,

Float price)

throws javax.ejb.CreateException {

// EJB 2.0 规范要求 ejbCreate 方法必须返回 null .

// 其中的 FIELDS 必须在此进行初始化:

// setSomeField("Something");

System.out.println("enter ItemBean.ejbCreate()...");

setItemID(itemID);

setSupplierID(supplierID);

setDescription(desc);

setQuantity(quanlity);

setPrice(price);

System.out.println("leave ItemBean.ejbCreate() ok!");

return null;

}

/**

* The container invokes this method immediately after it calls ejbCreate.

*/

public void ejbPostCreate() throws javax.ejb.CreateException {

}

/**

* @ejb.persistent-field

* @ejb.persistence

* column-name="ITEMID"

* sql-type="VARCHAR"

* @ejb.pk-field

* @ejb.interface-method

*/

public abstract java.lang.String getItemID();

/**

* @ejb.interface-method

*/

public abstract void setItemID(java.lang.String itemID);

/**

* @ejb.persistent-field

* @ejb.persistence

* column-name="SUPPLIERID"

* sql-type="VARCHAR"

*

* @ejb.interface-method

*/

public abstract java.lang.String getSupplierID();

/**

* @ejb.interface-method

*/

public abstract void setSupplierID(java.lang.String supplierID);

/**

* @ejb.persistent-field

* @ejb.persistence

* column-name="DESCRIPTION"

* sql-type="VARCHAR"

*

* @ejb.interface-method

*/

public abstract java.lang.String getDescription();

/**

* @ejb.interface-method

*/

public abstract void setDescription(java.lang.String description);

/**

* @ejb.persistent-field

* @ejb.persistence

* column-name="QUANTITY"

* sql-type="INTEGER"

*

* @ejb.interface-method

*/

public abstract java.lang.Integer getQuantity();

/**

* @ejb.interface-method

*/

public abstract void setQuantity(java.lang.Integer quantity);

/**

* @ejb.persistent-field

* @ejb.persistence

* column-name="PRICE"

* sql-type="DECIMAL"

*

* @ejb.interface-method

*/

public abstract java.lang.Float getPrice();

/**

* @ejb.interface-method

*/

public abstract void setPrice(java.lang.Float price);

/**

* business method

*

* @ejb.interface-method

**/

public ItemValue getItemValue() {

System.out.println("enter ItemBean.getItemData()");

System.out.println("leave ItemBean.getItemData()");

return new ItemValue(

getItemID(),

getSupplierID(),

getDescription(),

getQuantity(),

getPrice());

}

/**

* business method

*

* @ejb.interface-method

**/

public void fillStock(Integer quantity) {

System.out.println("enter ItemBean.fillStock()");

Integer qty = new Integer((quantity.intValue() + getQuantity().intValue()));

setQuantity(qty);

System.out.println("leave ItemBean.fillStock()");

}

}

anywn_ldh
2003-10-25 14:49
你好,能请教你一下,怎么配置eclipse+lamboz+jboss的啊?

anonymous
2003-10-25 16:57
按照指南文档来做。

猜你喜欢