-->
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.  [ 2 posts ] 
Author Message
 Post subject: JPA - Calling toString() triggers the proxy initialization
PostPosted: Tue Oct 23, 2007 6:12 pm 
Newbie

Joined: Fri Dec 02, 2005 2:48 pm
Posts: 13
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)?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 12:01 am 
Newbie

Joined: Fri Dec 02, 2005 2:48 pm
Posts: 13
Sorry...

According to documentation, toString() WILL really trigger the proxy initialization. Only equals(), hashCode() and identifier getter() won't!

Please, ignore this post!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.