Forums Register Login

Differecne between proxy and lazy attributes in <class> for hibernate hbm file

+Pie Number of slices to send: Send
--------------------------------------------------------------------------------
An object proxy is just a way to avoid retrieving an object until you need it. Hibernate 2 does not proxy objects by default. However, experience has shown that using object proxies is preferred, so this is the default in Hibernate 3.

Object proxies can be defined in one of two ways. First, you can add a proxy attribute to the class element. You can either specify a different class or use the persistent class as the proxy. For example:

<class name="Location"
proxy="com.manning.hq.ch03.Location"...>...
</class>
The second method is to use the lazy attribute. Setting lazy="true"is a shorthand way of defining the persistent class as the proxy. Let's assume the Location class is defined as lazy:

<class name="Location"lazy="true"...>...</class>
-------------------------------------------------------------------------------------

From the above mentioned comments, i want to know the difference between lazy="true" and proxy attribute when the proxy object is same as the class object

Also could somebody guide me with an example when the class object and the proxy object are different.
I want to know the structure difference between a class object and its proxy object
Hold that thought. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3061 times.
Similar Threads
How to lazily load references when the object is detached from session ?
Hibernate Mapping (Many-To-One Association). Problem. This forum is my last hope.
proxy problem
Loading proxy without hitting database
ORM Mapping, Best practices?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:53:21.