Gangadhara Melukote
asked on
JPA/Hibernate - insert/update/delete multiple records to DB
My question may looks like basic for JPA/Hibernate experts, since I did not explore much on Hibernate side and due to short of time, I had to post this question here.
I have a table EMPLOYEE and have some columns like EmpId (PK - generated through a sequence on insertion of each row), FirstName, LastName, Sal, Dept, status.. etc. I have java bean class where each row of employee table represents a java bean.
I am getting the employee details for every half an hour in an XML file and generating the beans list on parsing this XML (approx more than 10K records). Now I need to persist this data in DB (EMPLOYEE table) in the following manner:
1) If the employee record doesn't exist then create it. (insert row)
2) If the employee record exists and the respective data is changed then update it (nothing to do with the un change data)
3) If the employee record exists in the table but the respective bean doesn't there in the bean list, then I need to mark the 'STATUS' column as 'DELETED'.
Can some one please provide me better approach to achieve this?
Database: Oracle 11g
OS: Windows
IDE: Eclipse
Kindly let me know if any other details required.
I have a table EMPLOYEE and have some columns like EmpId (PK - generated through a sequence on insertion of each row), FirstName, LastName, Sal, Dept, status.. etc. I have java bean class where each row of employee table represents a java bean.
I am getting the employee details for every half an hour in an XML file and generating the beans list on parsing this XML (approx more than 10K records). Now I need to persist this data in DB (EMPLOYEE table) in the following manner:
1) If the employee record doesn't exist then create it. (insert row)
2) If the employee record exists and the respective data is changed then update it (nothing to do with the un change data)
3) If the employee record exists in the table but the respective bean doesn't there in the bean list, then I need to mark the 'STATUS' column as 'DELETED'.
Can some one please provide me better approach to achieve this?
Database: Oracle 11g
OS: Windows
IDE: Eclipse
Kindly let me know if any other details required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.