Discussions

EJB design: Entity - Session Bean(stateful) Communication...........

  1. I have 19 entity beans.....I want to contact all entity beans thro a Session Bean(Stateful)....Whether I have to write all methods which is in entity bean in Session bean.....Or else how I can achieve these things....
                                     Thanks...,
                                     Sundar.S,
                                     Bangalore
  2. well the session beans are supposed to represent ur business processes/flows/logic, the entity beans represent the entities which make up ur business.

    so lets say if u have business process which invloves registering a customer, u might wanna have a method "sessionbean.registerCustomer()" which takes various parameters/attributes (as serialised object) which represents a customer like name, age, gender etc.

    so ur code cud look somethin like this

    public void registerCustomer(Customer cust){

    custEntity.setName(cust.getName());
    custEntity.setAge(cust.getAge());
    custEntity.setGender(cust.Gender());

    }

    hope this helps

    kapil
  3. Kapil:

    I guess the example u have given is for a stateless
    session bean as u've put all the entity calls in a
    single session bean method implementation.

    Vaithi
  4. well the session beans are supposed to represent ur business processes/flows/logic, the entity beans represent the entities which make up ur business.

    so lets say if u have business process which invloves registering a customer, u might wanna have a method "sessionbean.registerCustomer()" which takes various parameters/attributes (as serialised object) which represents a customer like name, age, gender etc.

    so ur code cud look somethin like this

    public void registerCustomer(Customer cust){

    custEntity.setName(cust.getName());
    custEntity.setAge(cust.getAge());
    custEntity.setGender(cust.Gender());

    }

    hope this helps

    kapil