Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4068220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:20:54+00:00 2026-05-20T16:20:54+00:00

New to hibernate here. I’m using Hibernate 3.5, which I understand should use lazy

  • 0

New to hibernate here. I’m using Hibernate 3.5, which I understand should use lazy fetching by default. I have SQL logging enabled via

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

I’m requesting object A which has a reference to object B which holds the actual byte array of data. I pushed the data into object B so that the data doesn’t get fetched from the DB unless really needed, but when I request object A, the heap jumps drastically, as if it’s fetched the data anyway, and I get this output from hibernate SQL logging:

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

I’m unclear on how to interpret this, specifically the ‘as’ statement. The ‘attachment0.data’ seems to be the byte array in object B. Is hibernate saying that it’s created a proxy for the array, or is this saying it’s actually pulled the data from the DB? If it’s just created a proxy, would I see no select output for the proxy?

So in summary, the main question of how can I determine whether I have a proxy or real object, and the related question of how to interpret the select statement?

I have dived into the hibernate docs, as well as searched on the web quite a bit, but most of the info seems to be a step above the basic knowledge I’m missing, so any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:20:54+00:00Added an answer on May 20, 2026 at 4:20 pm

    The object you have can be a proxy with all the data loaded. If your want to unproxy the object use the following in Hibernate:

    From an org.hibernate.impl.SessionImpl you can get the org.hibernate.engine.PersistenceContext and then

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

    The javadoc for 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;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to hibernate and have stumbled on this problem, which I can't
I am using hibernate and have bi-directional relations. How should I correctly override equals()
I have the same issue using hibernate against DB2 and MySQL. Here is a
Hi i am new to hibernate technology and i have few issues. Suppose if
I am new to Hibernate. I have an exception while running an Hibernate-based application.
I am new to hibernate and I am stumped. In my database I have
I'm new to Hibernate and I'm struggling with problem: I have 3 tables and
I'm getting no improvement in speed when using Ehcache with Hibernate Here are the
I'm new to hibernate. I have a transaction that fails with a HibernateException, yet
I'm new to Hibernate ORM and I think you can help me understand it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.