javaee-samples / javaee7-hol

Java EE 7 Hands-on Lab
http://htmlpreview.github.io/?https://github.com/javaee-samples/javaee7-hol/blob/master/docs/javaee7-hol.html
Other
136 stars 92 forks source link

Integrity Constraint Violation #24

Open ayoubfalah opened 7 years ago

ayoubfalah commented 7 years ago

Hello Mr. Gupta,

First let me thank you for the great samples and well explanation.

I think that the controller MovieClientBean which is responsible for adding a new movie to the database associated with the Movie Plex 7 Web App does not work correctly. To identify the error let us consider the following scenario:

Step 1: Running the project Step 2: Clicking Movies in the left navigation bar. Step 3: Clicking the New Movie button. Step 4: Entering the data for a new movie, e.g., Movie Id: 22, Movie Name: Skyfall, Movie Actors: Daniel Craig Step 5: Clicking the Add button Step 6: Reloading you browser The Application server shows of trace of java.sql.SQLIntegrityConstraintViolationException, because when reloading the browser, the app tried to add the last added movie again to the database, this operation will be rejected by the DBMS, because the attribute Movie_Id must be unique.