List/combobox population - to use entity bean or not?

Discussions

EJB design: List/combobox population - to use entity bean or not?

  1. Hi,
    I am relatively new to EJB technology. I have 2 entity beans Employee and Department. I need to display a list of departments in the 'Employee Add' page. Should i populate the list using 'Department' entity beans (one bean for every list entry) or using a select query in a session bean ? What is the standard approach for populating such lists?

    srividhya
  2. hi sri,

    well the best wud be too let ur session bean either return a jdbc resultset or a string array department.

    u can also create a data structure(java class) to represent ur department. for eg a java class "Department" with code,description as attributes and then getters and setters for those attributes. and then ur session bean method cud return a array of Department objects. but do remember to make this class serializable. because if ur client-session bean method call is over the network, then u will be making network for each piece of data u try to fetch.

    u also mentioned entity beans well thats an option too. but if u have 100 dept then imagine u will be asking ur application server to manage 100 instances of entity beans. also entity beans always travel by reference , so take into consideration the amount of network trips.

    hope this helps

    lemme know

    kapil
  3. Some more ideas.

    1) If you are using a JSP page u could create a database connection and populate using the resultset object.

    2) You can use a servlet to retrieve data and the result can be published as a page for the user.