你想怎么用啊???
如果你要根据主键查询的话,你就得先给主键类设值,然后在查询里把主键类当作参数给实体Bean

解决方案 »

  1.   

    我感觉如果你的主键是一个属性的话,完全可以不用主键类,只用返回int或String 就可以
      

  2.   

    看你自己主键的定义呀...
    !!!
    setxxx();
     ------------------------------------------------------
               我们还年轻牛奶会有的奶牛也会有的 
                 可天天在 csdn 混这些会有吗 ??
      

  3.   

    我的主键类如下:
    package cpk;
    import java.io.*;
    public class RoleFunctionPK implements Serializable {
      public Integer roleID;
      public Integer functionID;
      public RoleFunctionPK() {
      }
      public RoleFunctionPK(Integer roleID, Integer functionID) {
        this.roleID = roleID;
        this.functionID = functionID;
      }
      public boolean equals(Object obj) {
        if (obj != null) {
          if (this.getClass().equals(obj.getClass())) {
            RoleFunctionPK that = (RoleFunctionPK) obj;
            return (((this.roleID == null) && (that.roleID == null)) || (this.roleID != null && this.roleID.equals(that.roleID))) && (((this.functionID == null) && (that.functionID == null)) || (this.functionID != null && this.functionID.equals(that.functionID)));
          }
        }
        return false;
      }
      public int hashCode() {
        return (roleID + "" +functionID).hashCode();
      }
    }
    我的客户端程序是用jbuilder做的,主方法如下:
    public static void main(String[] args) {
        RoleFunctionTestClient3 client = new RoleFunctionTestClient3();
        RoleFunctionPK fpk;
        fpk=new RoleFunctionPK(1,2);
        client.findByPrimaryKey(fpk);}
    fpk=new RoleFunctionPK(1,2);这句话总报错!
      

  4.   

    public class OrderitemPK implements java.io.Serializable {
      public java.lang.Integer orderid;
      public java.lang.Integer inventoryid;  public OrderitemPK() {
      }  public OrderitemPK(java.lang.Integer orderid, java.lang.Integer inventoryid) {
        this.orderid = orderid;
        this.inventoryid = inventoryid;
      }
      public boolean equals(Object obj) {
        if (this.getClass().equals(obj.getClass())) {
          OrderitemPK that = (OrderitemPK) obj;
          return this.orderid.equals(that.orderid) && this.inventoryid.equals(that.inventoryid);
        }
        return false;
      }
      public int hashCode() {
        return (orderid + "" +inventoryid).hashCode();
      }用的时候:
    ……
    OrderitemPK pk = new OrderitemPK(11,11);
    ……
      

  5.   

    不是和我做的一样吗》?
    fpk=new RoleFunctionPK(1,2)
    这句话有Constructor RoleFunctionPK(int,int) not found in class cpk.RoleFunctionPK
    错误!
      

  6.   

    你用下面的试试看
    public static void main(String[] args) {
        RoleFunctionTestClient3 client = new RoleFunctionTestClient3();
        RoleFunctionPK fpk;
        fpk=new RoleFunctionPK(new Integer(1),new Integer(2));
        client.findByPrimaryKey(fpk);}
      

  7.   

    晕了!!!!!
    应该是:
    OrderitemPK pk = new OrderitemPK(new Integer(11),new Integer(11));