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 6360563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:39:52+00:00 2026-05-24T23:39:52+00:00

I have come unstuck with this goal after successfully using a dataModel when rendering

  • 0

I have come unstuck with this goal after successfully using a dataModel when rendering the result from a hibernateTemplate().find
on another class where there isn’t a many-to-one mapping to another class.

Has anyone used a similar definition like the one below where you need all of ParentClass plus just one property from the child class.
In my Use case I need to display the receiptDate alongside all the other values contained in the ParentClass instance.

<hibernate-mapping> <class catalog="myCatalog" name="myCatalog.model.orm.MyClass" table="myTable">
<id name="consignmentId" type="java.lang.Integer">
  <column name="myTable_id"/>
  <generator class="identity"/>
</id>
<many-to-one class="myCatalog.model.orm.ParentClass" fetch="select" name="pTable">
  <column name="pTable_id" not-null="true"/>
</many-to-one>
<property name="receiptDate" type="timestamp">
  <column length="19" name="receipt_date" not-null="true"/>
</property> </class> </hibernate-mapping>

The nearest I have got is with:
hibernateTemplate().find(“select c.parentClass from myClass c”);

However when trying to adress the parentClass items e.g: parentClass.depotAddress
in the dataTable I get the following error as the parentClass has not been loaded:
org.hibernate.LazyInitializationException: could not initialize proxy – no Session

I would appreciate any pointers in the right direction.

I have just found a solution anyway, by forcing eager loading on the ParentClass via:

<many-to-one class="myCatalog.model.orm.ParentClass" lazy=false fetch="select" name="pTable">
  • 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-24T23:39:52+00:00Added an answer on May 24, 2026 at 11:39 pm

    Your question is far from being clear. If what you want to do is load all the MyClass instances along with their pTable parent, the query to use is

    select m from MyClass m inner join fetch m.pTable
    

    This is of course described in the Hibernate reference documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across this PHP code to check email address using SMTP without
I have come across a very weird error. I'm on Solaris 10, using Ruby
I’m having fun with EF and have come unstuck. Originally I used the following
I have come to Java from Visual Basic, and seem to think I have
I have come across this excellent blog explaining how to provide access to private
I have come across this question: If process A contains a pointer to a
I have come across this line of legacy code, which I am trying to
I have come to Grails without first being a Spring developer. This is great
I have come accross a strange problem that can be illustrated using the 2
I've come unstuck this particular problem as I'm still fresh to NHibernate/FluentNHibernate. I will

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.