EJB best practices


EJB design: EJB best practices

  1. EJB best practices (4 messages)

    Hi !
    I use Stateful Session bean and BMP entity bean for my system. I have 60 columns in a table which I have to retrieve (from the table) and update (to the table) with the user entered value for all the columns. I use JSP as my client. My system architecture is JSP client calls session bean which inturn calls entity bean for getting and setting the data. I've created a wrapper class with 60 attributes (corresponds to 60 columns of the table) and a constructor with 60 parameters, instead of having 60 setters and getters.
    I have some questions regarding this :

    1. Initially when the user logs in, he gets the value of the 60 columns data populated in the textfield. To do this, I've planned to call a method in a session bean, which inturn calls entity bean business method. In entity bean, I execute a query and instantiate the wrapper class with 60 column values of the retrieved record (query retrieves only one record) and finally returning the object itself as a whole. Is it a right approach, or if any better approach, pl let me know asap.
    2. For setting the values of the attributes (and updating to the table finally) with user entered values, how to do it.


    Threaded Messages (4)

  2. EJB[ Go to top ]

    The way that you have suggested your ejb implementation is the current way that we have implemented our e-commerce solution in. It gives the advantage of having the data cached rather than doing an ejbStore and ejbLoad every time that any piece of the data changes. So on that front it is a good design.

    I would like to question your table with 60 columns in it. This seems a little large - perhaps some normalisation is in order?

    For setting and getting the values to and from the database - this would be done with normal SQL eg INSERT INTO .... and UPDATE ... SET ... etc. Hope this is detailed enough for you :-)
  3. EJB[ Go to top ]

    Hi !
    Thanks for ur response. Could u tell me "in detail" about the two questions.

  4. Wrapper Class[ Go to top ]


    Am I right in assuming that the wrapper class you mention is not an EJB, just a regular java class? Could anybody tell me what the implications of this are? (i.e portability etc.)

    AJP I am curious as to how you will guarantee data integrity - what happens if a concurrent client graps the same data? Is this a problem in your application?


  5. EJB best practices[ Go to top ]

    It might be useful for you if you take a look at this article...