Saturday, November 24, 2012

Different States Of Hibernate POJO Class Object


3 States of Hibernate POJO class object :
 

1)Transient State                                                                                                 

2)Persistenet State                                                                                    

3)Detached State 

 

As we know already, Hibernate pojo class object contains data and we perforn certain DB operation in order to make this data(object data)  persist/manipulate and etc with DB..


--> Transient State object doesn't contain identity value and also doesn't represent record of the DB table because it is just created object of HB pojo class.


This State is not under the control of ORM S/w.....

-->Persistance State object Contains identity value,represent DB table record/Row and also maintains Synchronization with DB table record.                                                                               This object is required to develope persistance logic.

-->Detached State object contains object value but doesn't represent record & doesn't maintain Synchronzation with DB table record.


Every hibernate Application contains one logical memory called persistance context having persistance State HB pojo class object ...


In the above stuff i have used term Synchrinization and one more identity value.....

 

 

 

Synchrinization:                                                                                                         

*******************

So lets understand what Synchronization  is....


if we do modification on Pojo class object our intention is very clear that it should reflect on DB table record shouldn't it?                                                                                                                      and same thing done with DB table record should reflect on associate pojo class object

So Hibernate S/w gives flexiblity to do this and this is commonly known as Synchrinization...


if we go for definition of synchrinization so it would be something like...

Synchrinization : Modification done on pojo class object will be reflection in the record of DB table and vice versa.... 

 

 

IdentityValue:                                                                                                                           ***************                                                                                                                                

Identity Value is the criteria value/condition value that makes Hibernate s/w to know where(in which row) it has to perform certain DB operation...

otherwise how this Hibernate s/w will come to know that it has to perform operation in this perticular row..????

 For this purpose identity value is requierd...

 

 

 

 

* Programmer configure one or more member variable of HB pojo class as identity field.ORM s/w uses this member variable value as isentity value of HB pojo class object that are representing Db table rows.


*HB s/w internally identifies each HB pojo class object through its identity value & aslo uses that value as criteria /condition value to maintain Synchrinization b/w HB pojo class object and table records.


*HB s/w internally generates update query having identity value as criteria value to reflect the modification done in object to Db table records...(Object to Row Synchronization).


*HB s/w generates select query having identity value as criterai value to reflect the modification done n DB table record to object.. (DB Table record to Object Synchronization)..


No comments:

Post a Comment