A Gift entity is in a one-to-many relationship with a Product entity. An EJB developer writes a query to delete gifts
that have an item of "JPA" or "JSF" and writes the following Java Persistence query language statement.
DELETE FROM Gift g WHERE g.name IN ("JPA", "JSF")/
If the query with a PersistenceException, what can be the cause?
B. The query causes a foreign key integrity constraint to be violated.
C. The database does not have any users with the name "JPA" or "JSF".
Correct answer :B
Should C be the answer as well?
The specification 4.10 does not say whether the persistence provider will throw an exception if a record does not exist when DELETE is executed.
Note that: if the OneToMany relationship is an unidirectional relationship between Gift and Product there will be a JoinTable inbetween. Running the given delete query in that setup won't cause an exception to be thrown.
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
Devious Experiments for a Truly Passive Greenhouse!