0

I have a sequence of 5 forms that an user has to fill up in my system. On each submitted form, I send the data to my java server and store this data on mySQL database using Hibernate.

In this scenario, I may have some problems for example if an user give up of filling the form without having finished all the form "steps", cause I'd have incompleted data from this specific user.

To solve this, I have thought in creating extras tables similar to the ones that I have now and add a new column userId, which would identify the user filling the form. Once the user complete to fill all the forms, I would send the data to the "official" table, which does not have the userId column. This table would be read by the system.

Is there a way to easily to it using Hibernate? Or would I have to manually create new tables with one extra column and, once all form are submitted, move the data from the temporary table, to the definitive table (without userId)?

Felipe Mosso
  • 3,907
  • 11
  • 38
  • 61

1 Answers1

1
 On each submitted form, I send the data to my java server and store this 
 data on mySQL database using Hibernate.

This doesn't look to be a good idea to me. Rather than saving the form data to DB after submitting that form, maintain that in a session and only when the user has submitted final form, you can retrieve the data from session and save it in the DB. So if a user terminates in between before filling up all the forms, you don't have to do any rollback.

Mubin
  • 4,192
  • 3
  • 26
  • 45
  • thanks, this could be a possible solution for my problem! Do you if would have any problem to save a big amount of data on a user session? – Felipe Mosso Jun 17 '13 at 20:51
  • I have 5 list of Objects and each object has, on average, 5 String attributes and at least one another Object (with 5 String attributes and one another Object).. Each list will have, on average, 200 objects like Ive described before – Felipe Mosso Jun 18 '13 at 18:46
  • I will not have so many users creating profiles at the same moment, so I would have (5 lists)*(200 objects)*(5 strings)*(5 other string of another object) .. which will give me 2500 string per use.. let's supposed I have 4 users, i would store 100.000 Strings .. I don't know if I have made the right calc but it is something like this :) – Felipe Mosso Jun 18 '13 at 18:50
  • 1
    Well, that depends on the heap size used by the JVM of your application server. As a test, I would say, serialize all the objects/variables that belongs to one user (2500 strings) and write them to a file. Check the file size. If it doesn't go beyond a few MBs, then it should be fine to store that data in session. – Mubin Jun 18 '13 at 19:46