At the risk of oversimplifying the issue can anybody with a good understanding of the CGLib runtime proxies explain, from a Hibernate users perspective, the:
1) proxy lifecycle. Eg When are they created and returned, where are they stored and when are they replaced by the persistent entities they are proxying for.
and
2) proxy access sequence flow - eg. when a proxy is called, how is the call handled and how does it get to the target class / db etc
This is a mammoth topic and Im only after a 5 line summary of each. I have looked quite thoroughly through the site over the last few months and on this topic in the last week or so but this seems to a lightly documented topic at best with only some hints spread throughout the FAQs and online docs. I am really interested in understanding, to a shallow level at least, what happens.
******************************
Something like the following would be greatly appreciated (this is not accurate!!!!)
*****EXAMPLE 1*******
A call to session.load creates a proxy if there is none but doesnt initialize it, pulls it from the cache if one exists.
Any call to a proxy method hits the db and initializes the proxy with the db values.
Any call to a fully initialized instance that returns a hibernate mapped entity DOESNT return an instance, it returns a proxy as above. etc...
******** EXAMPLE 2 *************
Proxy creation - when a proxy is first created, it only knows its id and mapped class (highest in the hierarchy). This is also known as UNITIALIZED.
When a proxy method is called it is then INITIALIZED. This means that state is loaded into its properties from the DB. This is now a 'normal' JVM instance.
....
Sorry for the bizarre request and any and all help is very much appreciated!
cheers
Michael
|