Lesson - 50 : Hibernate - One To Many Delete Child Form Parent using XML and Annotation Config

Опубликовано: 05 Октябрь 2024
на канале: Sada Learning Hub
1,446
12

Hibernate – Assotations/Relationship : Remove a Child From a Parent Object In OneTo Many :
To remove one child object of a parent object, the following steos are required.
1. load parent object.
2. Read a collection of child objects from parent.
3. Load child objects.
4. Remove a child object from collection with in a transaction.
For ex: The following code adds one more customers to a vendor.
1. Vendor v = (Vendor)session.get(Vendor.class,111);
2. Set set = v.getCustomers();
3. Customer c = (Customer)session.get(Customer.class, 504);
4.Transaction tx = session.beginTransaction();
set.remove(c);
tx.commit();

Hibernate Examples Project Github Link : https://github.com/SadaLearningHub1/H...