General J2EE: About the mechanism of findByPrimaryKey

  1. About the mechanism of findByPrimaryKey (2 messages)

      I have define a findByPrimaryKey in Home interface which reture a Business_Check interface:
      public Business_Check findByPrimaryKey(String userName);

      and implement it in Bean:
      public String findByPrimaryKey(String userName) {
        return name;
      I want to known two questions:
      1. How does the EJB container can translate the returned String type to a Business_Check interface?
      2. Does the Home object find the EJB object in pool thought findByPrimaryKey?

    John Lee
  2. About the mechanism of findByPrimaryKey[ Go to top ]

    Hi John -

    In general with a BMP entity the situation is this:


      MyRemote findByPrimaryKey(MyPK pk);


      MyPK ejbFindByPrimaryKey(MyPK pk) {
        // make sure that the primary key exists in the db
        // and return it

    So, in the bean you have an ejbFindByPrimaryKey and in the home you have findByPrimaryKey.
    The beans job is to just return the primary key, the container will then take that, and wrap it up in a remote stub which will be sent back to the client (since the client called MyRemote remote = home.findByPrimaryKey(MyPK pk).

    Of course, your primary key class can be a String (like you have in your code). You need to make sure that you make the method ejbFindByPrimaryKey instead of what you have currently.


  3. About the mechanism of findByPrimaryKey[ Go to top ]

    Dion, Very thanks!

    John Lee