Discussions

EJB programming & troubleshooting: weblogic primary keys

  1. weblogic primary keys (1 messages)

    im getting this error even though the findByPrimaryKey is defenitely there in weblogic.

    [9.2.8] In EJB CspPasswordHome, the home interface must define the method.

    I think source of error maybe that i can't add the custon primary key i wrote to the drop down list for the primary key type. How can i add it to the drop down list, or if i specify object than how else might this eror be occurring??

    Threaded Messages (1)

  2. weblogic primary keys[ Go to top ]

    I'm kind of new to this too but I was able to create the .jar file with weblogic's ejbdeployer. I haven't tested it out yet though. Make sure your classes are similar to the following example.

    When you're in ejbdeployer and you click on Persistence, the primary key type should be selected to AuthorPK in this case. Make sure primary key field is set to none. hope this helps.

    //in the bean class
    public AuthorPK ejbCreate(String id) throws EJBException, CreateException {
        this.authorID = id;
        return null; //return null for container managed EJBs
      }

    No finder methods -- they are implemented by the container.

    //in the home interface
    public Author findByPrimaryKey(AuthorPK key) throws FinderException, RemoteException;

    //Primary key class

    /**
     * Primary Key class for 'Author' Container-Managed
     * Entity Bean
     */
    public class AuthorPK implements java.io.Serializable {
      
      /**
       * Note the primary key fields must be a
       * subset of the container-managed Bean fields.
       */
      public String authorID;

      public AuthorPK(String authorID) {
        this.authorID = authorID;
      }

      public AuthorPK() {
       //empty! required by EJB 1.1
      }

      public String toString() {
        return authorID;
      }
     
      public boolean equals(Object other) {
        if(other instanceof AuthorPK) {
          return authorID.equals( ((AuthorPK)other).authorID );
        }
        return false;
      }

      public int hashCode() {
        return authorID.hashCode();
      }
    }