0 Replies Latest reply on Jan 24, 2005 11:56 PM by cycchow

    Generation only supported with single PK field

    cycchow Newbie

      My entity bean have a compound key but when i deploy, the jboss always throw this exception:
      what does it mean?

      2005-01-25 11:19:20,737 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:jndiName=cotonenfant.ProductColor,service=EJB
      org.jboss.deployment.DeploymentException: Generation only supported with single PK field


      the following is my code

      package com.cotonenfant.ejb;
      
      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import javax.ejb.RemoveException;
      
      /**
       * @ejb.bean
       * name = "ProductColor"
       * local-jndi-name = "cotonenfant.ProductColor"
       * view-type = "local"
       * type = "CMP"
       * cmp-version = "2.x"
       * @ejb.util generate = "physical"
       * @ejb.finder
       * view-type = "local"
       * description = "findAll"
       * signature = "java.util.Collection findAll()"
       * result-type-mapping = "Local"
       * method-intf = "LocalHome"
       * @ejb.finder
       * view-type = "local"
       * signature="java.util.Collection findByProduct(java.lang.Integer pid)"
       * query="SELECT OBJECT(p) FROM ProductColor AS p WHERE p.productId=?1"
       * result-type-mapping="Local"
       * method-intf="LocalHome"
       */
      
      public abstract class ProductColorBean extends BaseEntityBean implements
       EntityBean {
      
       /**
       * @ejb.persistence
       * jdbc-type = "INTEGER"
       * column-name = "product_id"
       * sql-type = "integer"
       * @ejb.pk-field
       */
      
       public abstract java.lang.Integer getProductId();
      
       public abstract void setProductId(java.lang.Integer productId);
      
       /**
       * @ejb.persistence
       * jdbc-type = "VARCHAR"
       * column-name = "color"
       * sql-type = "varchar(10)"
       * @ejb.pk-field
       */
       public abstract java.lang.String getColorCode();
      
       public abstract void setColorCode(java.lang.String colorCode);
      
       /**
       * @ejb.persistence
       * jdbc-type = "VARCHAR"
       * column-name = "size"
       * sql-type = "varchar(10)"
       * @ejb.pk-field
       */
       public abstract java.lang.String getSize();
      
       public abstract void setSize(java.lang.String size);
      
       /**
       * @ejb.persistence
       * jdbc-type = "INTEGER"
       * column-name = "qty"
       * sql-type = "integer"
       */
       public abstract java.lang.Integer getQty();
      
       public abstract void setQty(java.lang.Integer qty);
      
       /**
       * @ejb.persistence
       * jdbc-type = "INTEGER"
       * column-name = "qty_sold"
       * sql-type = "integer"
       */
       public abstract java.lang.Integer getQtySold();
      
       public abstract void setQtySold(java.lang.Integer qtySold);
      
       public com.cotonenfant.ejb.pk.ProductColorPK ejbCreate(com.cotonenfant.
       dataobjects.ProductColorData data) throws javax.ejb.CreateException {
       this.setProductId(data.getProductId());
       this.setColorCode(data.getColorCode());
       this.setSize(data.getSize());
       this.setData(data);
       return null;
       }
      
      // public void ejbPostCreate(com.cotonenfant.dataobjects.ProductColorData data) {
      // }
      
       /**
       * @ejb:interface-method view-type="both"
       */
       public abstract com.cotonenfant.dataobjects.ProductColorData getData();
      
       /**
       * @ejb:interface-method view-type="both"
       */
       public abstract void setData(com.cotonenfant.dataobjects.ProductColorData data);
      
      }
      



      /*
       * Generated by XDoclet - Do not edit!
       */
      package com.cotonenfant.ejb.pk;
      
      /**
       * Primary key for ProductColor.
       */
      public class ProductColorPK
       extends java.lang.Object
       implements java.io.Serializable
      {
      
       public java.lang.Integer productId;
       public java.lang.String colorCode;
       public java.lang.String size;
      
       public ProductColorPK()
       {
       }
      
       public ProductColorPK( java.lang.Integer productId,java.lang.String colorCode,java.lang.String size )
       {
       this.productId = productId;
       this.colorCode = colorCode;
       this.size = size;
       }
      
       public java.lang.Integer getProductId()
       {
       return productId;
       }
       public java.lang.String getColorCode()
       {
       return colorCode;
       }
       public java.lang.String getSize()
       {
       return size;
       }
      
       public void setProductId(java.lang.Integer productId)
       {
       this.productId = productId;
       }
       public void setColorCode(java.lang.String colorCode)
       {
       this.colorCode = colorCode;
       }
       public void setSize(java.lang.String size)
       {
       this.size = size;
       }
      
       public int hashCode()
       {
       int _hashCode = 0;
       if (this.productId != null) _hashCode += this.productId.hashCode();
       if (this.colorCode != null) _hashCode += this.colorCode.hashCode();
       if (this.size != null) _hashCode += this.size.hashCode();
      
       return _hashCode;
       }
      
       public boolean equals(Object obj)
       {
       if( !(obj instanceof com.cotonenfant.ejb.pk.ProductColorPK) )
       return false;
      
       com.cotonenfant.ejb.pk.ProductColorPK pk = (com.cotonenfant.ejb.pk.ProductColorPK)obj;
       boolean eq = true;
      
       if( obj == null )
       {
       eq = false;
       }
       else
       {
       if( this.productId != null )
       {
       eq = eq && this.productId.equals( pk.getProductId() );
       }
       else // this.productId == null
       {
       eq = eq && ( pk.getProductId() == null );
       }
       if( this.colorCode != null )
       {
       eq = eq && this.colorCode.equals( pk.getColorCode() );
       }
       else // this.colorCode == null
       {
       eq = eq && ( pk.getColorCode() == null );
       }
       if( this.size != null )
       {
       eq = eq && this.size.equals( pk.getSize() );
       }
       else // this.size == null
       {
       eq = eq && ( pk.getSize() == null );
       }
       }
      
       return eq;
       }
      
       /** @return String representation of this pk in the form of [.field1.field2.field3]. */
       public String toString()
       {
       StringBuffer toStringValue = new StringBuffer("[.");
       toStringValue.append(this.productId).append('.');
       toStringValue.append(this.colorCode).append('.');
       toStringValue.append(this.size).append('.');
       toStringValue.append(']');
       return toStringValue.toString();
       }
      
      }