Can findByPrimaryKey find exist one in BMP entity bean.

Discussions

General J2EE: Can findByPrimaryKey find exist one in BMP entity bean.

  1. Hi:
       I have been puzzle by this.
       In my function of "findByPrimaryKey" is to select some data with the given primarykey and return it.
       Suppose I have create a BMP entity bean with primarykey equal with "AAA". Does the Container just retrieve the exist object with primary key equal with "AAA" or create a new one if I call findByPrimaryKey("AAA").

    Thanks!
    John Lee
  2. In BMP, your job in the bean class is to implement:

      YourPK ejbFindByPrimaryKey(YourPK pk);

    This normally means, that you take the pk, do a select on the database where yourpk=?. If the db finds a row, you can simply return pk;, else throw new ObjectNotFoundException(...).

    The container then takes that primary key, wraps it up in a remote stub which gets sent back to the "client" (whoever called home.findByPrimaryKey(YourPK);