GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Hibernate
Go To First  |  Previous Question  |  Next Question 
 Hibernate  |  Question 24 of 33    Print  
What is Hibernate proxy?

  
Total Answers and Comments: 3 Last Update: May 19, 2008     Asked by: Saurabh Jain 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: arindam_0006in
 
Proxies are created dynamically by subclassing your object at runtime. The subclass has all the methods of the parent, and when any of the methods are accessed, the proxy loads up the real object from the DB and calls the method for you. Very nice in simple cases with no object hierarchy. Typecasting and instanceof work perfectly on the proxy in this case since it is a direct subclass.

Above answer was rated as good by the following members:
getravi2k, geeky920
July 12, 2007 14:58:40   #1  
rajneeshg Member Since: July 2007   Contribution: 3    

RE: What is Hibernate proxy?
Class can be mapped to a proxy instead to a table. When you actually call load on session it returns you proxy. This proxy may contain actual method to load the data.

May be used when you already some pre-existing code for persistence and you want to call it via Hibernate

 
Is this answer useful? Yes | No
July 12, 2007 16:36:30   #2  
rajneeshg Member Since: July 2007   Contribution: 3    

RE: What is Hibernate proxy?
By default Hibernate creates a proxy for each of the class you map in mapping file. This class contain the code to invoke JDBC. This class is created by hibernate using CGLIB

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
May 19, 2008 13:48:22   #3  
arindam_0006in Member Since: August 2007   Contribution: 15    

RE: What is Hibernate proxy?
Proxies are created dynamically by subclassing your object at runtime. The subclass has all the methods of the parent and when any of the methods are accessed the proxy loads up the real object from the DB and calls the method for you. Very nice in simple cases with no object hierarchy. Typecasting and instanceof work perfectly on the proxy in this case since it is a direct subclass.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape