The proxy is being initialized even without overriding Object.toString().
Code:
-- begin new Persistence Context --
Order order = entityManager.getReference(Order.class, new Long(1)); // returns a proxy instance
order.toString(); // no overriding toString() from superclass
-- end --
Output (after calling toString()):
Code:
Hibernate:
select
order0_.id as id1_0_,
order0_.xxx as xxx1_0_,
order0_.yyy as yyy1_0_
from
Order order0_
where
order0_.id=?
The document (
http://www.hibernate.org/hib_docs/refer ... mance.html) says:
Quote:
Certain operations do not require proxy initialization
* equals(), if the persistent class does not override equals()
* hashCode(), if the persistent class does not override hashCode()
* The identifier getter method
Is this behavior specific for 'Hibernate EntityManager' (JPA)?