sam98uele / DB2Project_EJB

3 stars 0 forks source link

Questionnaire marketing answer order bug #12

Closed mattia1p closed 3 years ago

mattia1p commented 3 years ago

When the marketing answers are subbitted the order of them when they are saved in the DB is not the inserted one

sam98uele commented 3 years ago

To fix it we could insert a new field in DB (and then also in the Entity) called Order. And then in the query adding ORDER BY Order

I wait for the approval to perform these fix @alessandriniluca @mattia1p

alessandriniluca commented 3 years ago

I've got a question: What do you mean about the order of the answers? you mean that the order of the users is shuffled, for example: Order of responses:

  1. User A
  2. User B
  3. User C

And when displaying the reviews, they appear for example in the order:

  1. User B
  2. User C
  3. User A

? If the problem is this one, I think that the most simple and correct solution is the one that proposed @sam98uele . Only thing: if you want to perform this solution, advise us when we need to do the merge of the DB.

sam98uele commented 3 years ago

The problem was that the Admin inserts the questions like:

  1. Question 1 text
  2. Question 2 text
  3. Question 3 text but, JPA then inserts them in the order it wants (randomly), so, it can happen that we have them in the response form in the order:
  4. Question 2 text
  5. Question 1 text
  6. Question 3 text (for example)

This is due to the fact we order them by the Primary Key.

P.S. I've made a lot of changes in the DB. So, I'll made this one ASAP, then I'll let you know when to update the model

alessandriniluca commented 3 years ago

Ok, I understood the problem. I think that your solution should be the best one. Perfect, thank you!