Monday, 11 March 2019

Hibernate CURD Operations PART-1

CURD Operations in Hibernate:
=====================================
1. Insert Opeartion
-----------------------------
->by save() method
->by persist() method
-> by saveOrUpdate() method

For example:

by save() method:
----------------------------
1. It return the PK.

by persist() method
1. it returns void (will NOT return any value)

by saveOrUpdate() method
------------------------------
1. If record doesn't present in db table then it will perform save operation.
2. If record present in db table then it will perform update operation.
3. It will check record by based on PK.
4. It returns void (will NOT return any value)






2. Update Opeartion
-------------------------------
1. by update() method
2. by saveOrUpdate() method
3. by merge() method


by update() method
--------------------------------
1. HB directly perform update command based on PK.
2. If record doesn't exist in table based on PK then exception will throw at run time.
3. If bean class object data and table data are same the unnecessary update query will be performed by
the HB.
4. upadate() method NOT at any cost will peform upadate operation successfully.
5. return type is void

by merge() method
---------------------------
merge() method at any cost peform upadate operation successfully.
return type is void

Case 1:
If record present in table
->If data is different then HB - select and upadte
->If data is same then HB - select

Case 2:
If record NOT present in table
->First HB - select (check the data)
->HB - insert




3. Delete Opeartion
-------------------------------
1. by delete() method
Case 1: If record exist in the table
->HB - Select and then delete

Case 2: If record NOT exist in the table

->HB perform only select for check the record



No comments:

Post a Comment

Access attributes in component

NOTE: To access an attribute in a  component , use expressions as  {! v.<Attribute Name>} . ----------------------------------------...