Kengkaj, Kengkaj, Kengkaj! Stop thinking like an SQL developer!
JPA is based on Objects, like Java. We don't just throw around numeric ids and column names. We are Java people!
The delete method takes an object. You just pass in an object. Which object do you want to delete? Just pass it in. Does it have a composite key, a sequence generated key, a numeric key or text key? [b]We don't care, we are Java developers.
Of course, the object we pass in will have an id in it. It will also be of a certain type of class. So, JPA, given the class, and the object that will obviously have an id embedded somwhere inside of it, can delete the underlying data, be it from one table, or spread across multiple tables, as those uncouth database designers are loath to do.
To be honest, if you just want to delete a row, given an id, you can do something like this:
That basically just passes an empty object with an id to the EntityManager or Hibernate Session for an immediate delete.
Anyway, I'm not convinced by the reason think objects, using your logic, JPA should not have find by id?
If we want to find an object which we know its id, we need to create an empty object, set id to it, and pass to a find method? Not make sense to me. And JPA doesn't do that, it has a find by id method.
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad: