mengzhihai
发贴: 0
积分: 0
|
于 2003-07-04 15:37
stuggle帮我看看...在jb中编译时提示如下错误.....
"Products.ejbgrpx": ERROR: Error from ejbc: "Products.ejbgrpx": In EJB Products, the ejbCreate method: ejbCreate(java.lang.String,java.lang.String,java.lang.String,double) must return the primary key type. "Products.ejbgrpx": ERROR: ejbc found errors 总是提示返回值的问题:起初是本地接口中,然后我把productsPK改成Object... 就又提示ejbCreate方法了....
代码如下:多谢了!!! ProductsBean.java
package product;
import javax.ejb.*;
abstract public class ProductsBean implements EntityBean { EntityContext entityContext; public ProductsPK ejbCreate(String productID, String name, String description, double basePrice) throws CreateException { System.out.println("ejbCreate() called");
setProductId(productID); setName(name); setDescription(description); setBasePrice(basePrice);
return new ProductsPK(productID); } public void ejbPostCreate(String productID, String name, String description, double basePrice) throws CreateException { System.out.println("ejbPostCreate() called"); } public void ejbRemove() throws RemoveException { System.out.println("ejbRemove() called."); } public abstract void setProductId(java.lang.String productId); public abstract void setName(java.lang.String name); public abstract void setBasePrice(double basePrice); public abstract void setDescription(java.lang.String description); public abstract java.lang.String getProductId(); public abstract java.lang.String getName(); public abstract double getBasePrice(); public abstract java.lang.String getDescription(); public void ejbLoad() { System.out.println("ejbLoad() called."); } public void ejbStore() { System.out.println("ejbStore() called."); }
public void ejbActivate() { System.out.println("ejbActivate() called."); } public void ejbPassivate() { System.out.println("ejbPassivate() called."); } public void unsetEntityContext() { System.out.println("unsetEntiryContext called"); this.entityContext = null; } public void setEntityContext(EntityContext entityContext) { System.out.println("setEntiryContext called"); this.entityContext = entityContext; } }
ProductsPK.java
package product;
import java.io.Serializable;
public class ProductsPK implements Serializable { public String productId;
public ProductsPK(){ }
public ProductsPK (String productId){ this.productId=productId; }
public boolean equals(Object obj){ if(obj!=null){ if(this.getClass().equals(obj.getClass())){ ProductsPK that=(ProductsPK)obj; return(((this.productId==null)&&(that.productId==null))||(this.productId!=null&&this.productId.equals(that.productId))); } } return false; }
public int hashCode(){ return productId.hashCode(); }
public String toString(){ return productId.toString(); } }
ProductsRemote.java
package product;
import javax.ejb.*; import java.util.*; import java.rmi.*; import java.math.*;
public interface ProductsRemote extends javax.ejb.EJBObject { //public void setProductId(String productId) throws RemoteException; public String getProductId() throws RemoteException;
public void setName(String name) throws RemoteException; public String getName() throws RemoteException;
public void setBasePrice(double basePrice) throws RemoteException; public double getBasePrice() throws RemoteException;
public void setDescription(String description) throws RemoteException; public String getDescription() throws RemoteException; }
ProductsRemoteHome.java
package product;
import javax.ejb.*; import java.util.*; import java.rmi.*;
public interface ProductsRemoteHome extends javax.ejb.EJBHome {
public ProductsRemote create(String productID, String name, String description, double basePrice) throws CreateException, RemoteException;
public Collection findByName(String name) throws FinderException, RemoteException;
public Collection findByDexcription(String description) throws FinderException, RemoteException;
public Collection findByBasePrice(double basePrice) throws FinderException, RemoteException;
public Collection findExpensiveProducts(double minPrice) throws FinderException, RemoteException;
public Collection findCheapProducts(double maxPrice) throws FinderException, RemoteException;
public Collection findAllProducts() throws FinderException, RemoteException;
public ProductsRemote findByPrimaryKey(Object pk) throws FinderException,RemoteException; }
我把上面的findByPrimaryKey中参数的类型换成主键类类型,提示如下错误: "Products.ejbgrpx": ERROR: Error from ejbc: In EJB Products, the home interface's findByPrimaryKey methods parameter must be the primary key type or java.lang.Object: {1} "Products.ejbgrpx": ERROR: ejbc found errors 改成object后提示上面错误....
多谢!!!!
|