This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a query.. Its written in hibernate's document that hibernate can access even private & protected methods. It goes as --- " we usually don't manipulate the identity of an object, hence the setter method should be private. Only Hibernate will assign identifiers when an object is saved. You can see that Hibernate can access public, private, and protected accessor methods, as well as (public, private, protected) fields directly."
In plain java, we can't access the private methods outside the defined class. Then how is it that hibernate is able to access any of the accessor methods.
In plain java, we can't access the private methods outside the defined class
Yes we can, if by "plain java" you mean the core APIs. The Reflection API includes a way to change the access flag for fields and methods (look at the setAccessable() method). I can't say whether Hibernate does it this way (have a look in the code and you should be able to find out) but its probable they do.