This discussion is archived
6 Replies Latest reply: Feb 16, 2012 3:45 AM by 698065 RSS

Need Suggestion for design

698065 Newbie
Currently Being Moderated
Hi,

My application is based on multiple forms. When user logged into application he has list of programs.
Now each program has multiple forms which need to field step by step and at the last page it should save the data.

So, right now as per our design we create bean for each form, each bean has at least 20 variables and generate their objects with session scope. When use exit from the last page we manually remove all the objects.

Now the problem with this pattern is that we receive PemGenSpace error in every week.

The reason is we use to store large object to session.

Can you please suggest me a better solution to overcome this problem?

Thanks.
  • 1. Re: Need Suggestion for design
    EJP Guru
    Currently Being Moderated
    Save the data in the database immediately per form, with autoCommit=false, and commit or rollback as appropriate at the last page.
  • 2. Re: Need Suggestion for design
    698065 Newbie
    Currently Being Moderated
    Thanks for reply.

    That was good idea that solved one of the problem. Other thing is that we need to give a functionality where user can jump from any form to any other form.
    So let say if user is on 4th form now if he jumps to the 1st form we have to fetch it from the database that is also cost to performance.

    To save this cost we use to save the data into session. As per your suggestion if we save data to DB with auto commit false then are we able to retrieve those data from DB?
  • 3. Re: Need Suggestion for design
    EJP Guru
    Currently Being Moderated
    So let say if user is on 4th form now if he jumps to the 1st form we have to fetch it from the database that is also cost to performance.

    To save this cost we use to save the data into session.
    Which has its own cost, which is much higher, as your server stops working.

    It is futile to quibble about a database lookup or two when your cure is worse than the disease. You have to put the data somewhere else, that doesn't cost memory. In other words, the database.

    What we have here is premature optimization. Have you even measured what the cost of the extra lookups is?
    As per your suggestion if we save data to DB with auto commit false then are we able to retrieve those data from DB?
    Of course, as long as it's inside the same transaction.
  • 4. Re: Need Suggestion for design
    698065 Newbie
    Currently Being Moderated
    If i understand correctly then i have only 2 options either i save them to database or store them to session.
    Depends on the size of data we should prefer the option like if its large number of data then database is preferred option and in reverse case session.

    Am i correct?
  • 5. Re: Need Suggestion for design
    EJP Guru
    Currently Being Moderated
    If i understand correctly then i have only 2 options either i save them to database or store them to session.
    You don't understand correctly. Nobody has said any such thing. I have suggested one alternative that will work. There may be others.
    Depends on the size of data we should prefer the option like if its large number of data then database is preferred option and in reverse case session.
    That is mostly meaningless gibberish, but I reiterate what I said above. There is no point in comparing the performance of a solution that doesn't work with the performance of a solution that does work. You can get the wrong answer, or a down server, in zero time, if that's the objective. It isn't.
  • 6. Re: Need Suggestion for design
    698065 Newbie
    Currently Being Moderated
    ok got it. So this is just the suggestion of my problem which is objective.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points