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