InterviewSolution
| 1. |
Name some important annotations used for Hibernate mapping with a simple example? |
|
Answer» Hibernate has a feature to monitor all persistent object properties. Whenever an entity is loaded through hibernate, it makes an additional copy of that whole entity object along with all the entity's property values. Irrespective of a change in one property or multiple properties, Hibernate checks all the objects properties. It detects which objects have been modified and then calls update statements on all updated objects. Once the changes or modifications are identified, a transaction is performed using the session object. So, if a session object is open and an object property is modified, the data is SYNCHRONIZED in the database. The data will be synchronized but will not be committed, till the session object's COMMIT() method or flush() method is called. Both synchronization and committing of code will happen together when the commit method is called. This process of monitoring all the persistent or MANAGED objects and updating only the CHANGED object properties is called automatic dirty checking. Dirty checking helps the user or DEVELOPER to avoid the time-consuming database write actions. This feature makes necessary updates or changes to the fields based on the changes made to the objects of the mapped class and the remaining fields are left unchanged or untouched. |
|