Wrapping Entity Beans In Session Bean Or Lazy Load Beans


EJB design: Wrapping Entity Beans In Session Bean Or Lazy Load Beans

  1. Hi Guys,
    This msg was posted earlier also and I am putting it up in more details for better responses. I am basically developing a web bases TIME SHEET SUBMISSION SYSTEM. These Time Sheets are submitted by consultants of company from client locations to parent HR Deptt. TS are submitted bi-weekly but each consultant can fill his work hours every day. Also a consultant may be working on multiple projects and may divide his entire day into these projects.
    I will elaborate on my problem I have following details in database tables:

    1. Consultant Details i.e name,add1 etc.
    2. Consultant Leave Details i.e different kind of leave authorised to an consultant(annual leave,sick leave etc) and leave availed by him.This table has ConsultantId as foreign key.
    3. ProjectDetails table, it contains project details and ProjectID.
    4. ConsultantProject mapping table that contains multiple ProjectId's and corresponding ConsultantID i.e for a given project this table has an ProjId-ConsultantId entry for every consultant working on this project.
    5. A timesheet Table that has time put in by a consultant for a week for a particular project. Each row will have ConsultantID,ProjectId as foreign key and hours for everyday of that particular week.

    Now the problem is when the Consultant choose my TimeSheet option I show him a time sheet which is pre populated with his details(name,worklocation etc),his leave details(i.e leave availed and remaining) and hours filled by him for current week (if it is not first day of week) for every project he is working on.

    I am mapping ConsultantTable,TimeSheet Table ,ProjectConsultant Table and Project table as EntityBeans. I am taking leave table as dependent object
    The approach I am trying to take is to have a Stateful Session Bean and lookup Consultant Bean,lookup leave details through JDBC, get ProjectPrimaryKey of all projects of a Consultant thru Consultant-Project mapping and finally return one JavaBean populated with all data or may be multiple java beans.

    Another approach is to look up all related Entity Beans in Consultant Entity Bean and lazy load them.

    Your comments will be appreciated.
  2. Ishtmeet,

      Your architecture is now a lot clearer. Sorry for not replying earlier to your original post.

      Your debate is a classic one, JDBC or Entity Beans? I would personally go with Entity Beans, because:

    1) Its object oriented
    2) JDBC to access particular tables are encapsulated behind the appropriate entity beans.
    3) your business objects don't know about databases, they only work with logic.
    4) Your system will be more maintainable.
    5) Your system will be faster if you use app. server caching. When your consultant navigates the form, presses reload, etc, all the data will be coming from an in-memory set of entity beans, rather than through the database.
    6) You can always switch back to JDBC if you find performance is bad.

       You allready have your entity beans written, why not use them?