primary key class in ejb2.0(weblogic server6.0)


EJB design: primary key class in ejb2.0(weblogic server6.0)

  1. how can i create a composite primary key class in ejb2.0, is it similer as we create in ejb1.1 if not please provide some working example of creating a primary key class in ejb2.0
  2. If I can remember correctly in EJB2.0 you code the primary key class to have get and set methods that correspond to the abstract get and set methods for the key fields in your EJB.
    For Example
    The EJB below has three attributes. PosPorTypeCode and PosPorCode are the primary key attributes.

    public abstract class PosPorEJB extends EntityBean {
        public abstract String getPosPorTypeCode();
        public abstract void setPosPorTypeCode(String value);
        public abstract String getPosPorCode();
        public abstract void setPosPorCode(String value);
        public abstract int getPrimaryInd();
        public abstract void setPrimaryInd(int value);

    The primary key class would look like this. (I have not included the hashCode and equals methods)

    public class PosPorPK implements Serializable {
        public String posPorTypeCode;
        public String posPorCode;
        public PosPorPK() {

        public String getPosPorTypeCode() {
            return posPorTypeCode;
        public void setPosPorTypeCode(String value) {
            posPorTypeCode= value;
        public String getPosPorCode() {
            return posPorCode;
        public void setPosPorCode(String value) {
            posPorCode = value;

        // Need to code hashCode and equals methods