How can I determine if hibernate has a "lazy" loaded proxy or real object?

New to sleep here. I am using Hibernate 3.5, which, as I understand it, should use the lazy default selection. I have SQL registration using

<property name="show_sql">true</property>

I am requesting an object A that has a reference to an object B that contains the actual array of data bytes. I pushed the data into object B so that the data is not retrieved from the database if it is really necessary, but when I request object A, the heap jumps abruptly, as if it were extracting data anyway, and I get this output from the sleep mode Logging SQL:

Hibernate: select attachment0_.id as id11_0_, attachment0_.data as data11_0_ from attachment_data attachment0_ where attachment0_.id=?

I do not understand how to interpret this, in particular, the expression "how." "Attachment0.data" seems to be a byte array in object B. Is hibernation a statement that it created a proxy for the array, or does it say that it actually pulled data from the database? If he just created a proxy server, I would not see the output for the proxy server?

So, in general, the main question is how can I determine if I have a proxy server or a real object, and the related question is how to interpret the select statement?

I plunged into hibernate docs and also searched the Internet for quite a bit, but most of the information seems to be a step above the basic knowledge that I lack, so any help is appreciated.

+5
1

, , - . , Hibernate :

org.hibernate.impl.SessionImpl org.hibernate.engine.PersistenceContext,

SessionImpl session = ...;
PersistenceContext persistenceContext = session.getPersistenceContext();
Object entity = persistenceContext.unproxy(maybeProxy);

javadoc unproxy

/**
 * Get the entity instance underlying the given proxy, throwing
 * an exception if the proxy is uninitialized. If the given object
 * is not a proxy, simply return the argument.
 */
public Object unproxy(Object maybeProxy) throws HibernateException;
+3

All Articles