I have read the book "Java Persistence with Hibernate" and studied the CaveatEmptor Native code.
But I have a question.
In order to save a CategorizedItem I need to do this:
CategorizedItem cItem = new CategorizedItem("Scott", Category, Item);
CategorizedItemDao.makePersistent(cItem)
But in order to delete a CategorizedItem I need to do this:
Category.getCategorizedItems().remove(cItem)
BTW, do I need to save the category then again, in order to delete the categorized item?
My Question is:
Is this efficient? Because when I have lots of items in my category, then all items are read from the database when I do: Category.getCategorizedItems()
Why can't I just do: CategorizedItemDao.makeTransient(cItem);
I think this is much simpler.
|