• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

My exam cloud mock exam 1 : Bulk delete data that does not exist  RSS feed

 
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
Creator of Enthuware JWS+ V6
Posts: 3272
296
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Should C be the answer as well?


No, that does not cause the transaction to fail.

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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!