sam98uele / DB2Project_EJB

3 stars 0 forks source link

Design of query #11

Closed alessandriniluca closed 3 years ago

alessandriniluca commented 3 years ago

I need to perform a delete on the db, of the questionnaire response about a given product id. What do you think it is better between the following options that I thought:

  1. Deleting directly the questionnaire in the database with a named query. This would work becaue when you are retrieving the questionnaire, you will query the database (so, it is all up to date), and because the cascade type includes the refresh;
  2. Deleting entities with a pattern similar to Remove - select - Remove and then flushing changes to the database (Ref. to page 23 of the set of slides 05-4-JPA-JPQL for further information about the pattern)

In case, we need to agree on the decision for the final evaluation of the project. Here my consideration:

  1. This could be better in terms of readability of the code, we would have a more thin code;
  2. I think that this is more "JPA style", could lead to a little bit less immediate code, but more appreciable
sam98uele commented 3 years ago

The better way to remove a product is using the EntityManager enterface with the: void remove(Object entity) method of the entity manager

alessandriniluca commented 3 years ago

Ok, I'll procede with the method of the entity manager, thank you