Sunday, August 21, 2016

HIBERNATE: Proxy Objects & FetchType attribute

Hibernate by default uses lazy fetching of associated objects which may throw exceptions if the session closes before fetching the inner objects.




 Hibernate uses something called Proxy objects to optimize the performance. It has all the basic class members excluding the COMPOSITE ones in this case. Upon request for the same, it then fetches it from the database.





This can be overridden by setting fetch type as EAGER as in the example below:



No comments:

Post a Comment