do entity beans represents a row in a table(s)


EJB design: do entity beans represents a row in a table(s)

  1. do entity beans represents a row in a table(s) (1 messages)

    I am doing a small EJB app (exam), in which there are 2 tables,questions_master and options_master.
    I am unclear abt how i should desing the EJB's my logic is , every question has more than one options, questions have id and ans_id, where as options have question_id (id=question_id)and sr_no(sr_no==ans_id),and there respectiive display string.

    1 - should i go in for two ejb's for two table's and handle them indepently (in which case where should i code the business logic i.e a question should have more then one answer, there should be no unlinked options etc...),
    2 - define only one bean (questionsEJB)and add a business method inside it to handle the options_master table.
    (which looks more convincing to me as a complete business component, which will also take care that options are not entered independently of questions)

    another way of looking at it is say...
    my entity is not a row in a table (questions_master )but,

    a row from a table (questions_master)and more than one row from a different table (options_master)...

    how do i create a complete enterprise entity bean from the above...

    any help in this regard would be highly appreciated
    thanx in advance.
    cpyder at usa dot net

  2. Hello,

    The second option you have suggested is surely the better one, if you plan to stick to CMP Beans. Another option will be to have a special session bean handle two CMP Entity Beans mapped to each table. find the question bean first and with the help of question_id implement a finder method that will return a collection of the optional answers. I think the option you suggested is a better one, simply due to performance and coding time.

    A simpler solution will be to use a BMP Bean and write your own SQL.