-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate get() method and proxy
PostPosted: Thu Nov 12, 2009 3:01 am 
Newbie

Joined: Thu Nov 12, 2009 2:21 am
Posts: 1
i read the hibernate document about the get() method section. the get() method return a persistent object, not a proxy. however, if i setup Hibernate cache and get() the same object twice in the same Hibernate Session, i will have got a proxy, not a persistent object. in that case, i have to deal with the casting and instanceOf operator problems and others.
for example:
These codes were executed in the same Hibernate Session.
Code:
Object a = hibernateDAO.get(new Long(1000));
...
Object b = hibernateDAO.get(new Long(1000));


result:
object a is a persistent object.
object b is a proxy.
my solution:
in the DAO layer, i just unproxy the return object. i overwrite the get() method:
Code:
public IBoBase get(final Object id) throws DataAccessException {     
        return (IBoBase) ProxyUtil.unproxy(getHibernateTemplate().get(classOfHandledBO, (Serializable) id));
}


my question:
does my unproxy thing can affect the performance of hibernate?

thank you for your helps


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

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.