-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: hibernate persistence - behind the scenes
PostPosted: Tue Jul 03, 2007 12:36 pm 
I am trying to understand how the constructor methods work in the persisting objects.

I would like to know when the object will be instantiated? is it during the first db operation? what happens after that? does hibernate query the tables and store the data in objects?


Is there a document that explains what exactly happens from start to end while using hibernate to persist the objects?


Top
  
 
 Post subject:
PostPosted: Tue Jul 03, 2007 2:44 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
It depends on what you do :
* For insert/update, then Hibernate doesn't have to create any object and will "just" use reflection to access your properties. In this case, most of the time, only your code will just have done a completely classical new somewhere.

* For loading, then yes, it will use the default constructor (could be less visible than public btw) and then call the needed setters after having executed the SQL code through JDBC.

In case you don't know, remember that Hibernate makes heavy use of class generation (dynamic proxy, for example), reflection and so on. Actually, for example, when instantiating an object at runtime when you request one to be loaded, it dynamically creates classes that inherits your POJO. That's why Hibernate can access protected fields and methods without any problem (it can also access private field with a small additional conf, btw).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject: What you need to add in order to let access to private field
PostPosted: Tue Jul 03, 2007 2:52 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
As far as i know you dont need any change.

How can hibernate access to private fields


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.