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

  • Home
  • SEARCH
  • 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 3286490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:23:10+00:00 2026-05-17T20:23:10+00:00

I have two tables: foo (primary key: foo_id) and foo_entry (primary key: foo_entry_id; foreign

  • 0

I have two tables: foo (primary key: foo_id) and foo_entry (primary key: foo_entry_id; foreign key: foo_id).

Below is my Hibernate config.
My problem is, when I call getAttributes() on the FooModel class, I end up with a list of a little over one million null objects. (foo table has ~200 rows, foo_entry has ~10,000).

I’m new to Hibernate and suspect I am just overlooking or am just not understanding something very, very basic. Any help appreciated!

<hibernate-mapping package="com.blah.www">
  <class name="FooModel" table="foo">
    <id name="fooId" column="foo_id"></id>

    <list name="attributes" table="foo_entry">
      <key column="foo_id" />
      <index column="entry_id" />
      <one-to-many class="FooEntryModel" />
    </list>
  </class>
</hibernate-mapping>

<hibernate-mapping package="com.blah.www">
  <class name="FooEntryModel" table="foo_entry">
    <id name="fooEntryId" column="foo_entry_id">
      <generator class="native" />
    </id>

    <property name="fooId"      type="int"       column="foo_id"      /> 
    <property name="attrName"   type="string"    column="attr_name"   />
    <property name="attrValue"  type="string"    column="attr_value"  />
    <property name="startDate"  type="timestamp" column="start_date"  /> 
    <property name="endDate"    type="timestamp" column="end_date"    />
  </class> 
</hibernate-mapping>
  • 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-17T20:23:10+00:00Added an answer on May 17, 2026 at 8:23 pm

    Sigh…

    This turned out to have a very logical (and very subtle) explanation.
    I had misunderstood and hijacked the semantics of the <index> (also known as <list-index>) tag within <list>. Namely, given:

    <list name="attributes">
        <key column="foo_id" />
        <index column="some_integer_value" />
        <one-to-many class="FooEntryModel" />
    </list>
    

    … I thought was referring to the attribute by which you want to order the list. In fact, it refers to an attribute whose value denotes at what index position within the list to insert the overall object. It’s meant to be a placeholder attribute, maintained and used entirely by Hibernate.

    The value of the “some_integer_value” to which I was mapping varied in my test data. Sometimes the value was less than a 100. Sometimes it was greater than a million.

    Thus, upon mapping just one row where “some_integer_value” == e.g. 100,001, Hibernate would create a list with that object inserted in the 100,001st position. Every list member preceding it, naturally, would be null.

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

Sidebar

Related Questions

I have two tables, we'll call them Foo and Bar , with a one
I have two tables named foo and bar , hypothetically speaking. foo has columns
Having difficulty articulating this correlated subquery. I have two tables fictitious tables, foo and
Suppose I have a database table with two fields, foo and bar. Neither of
I have two tables that are joined together. A has many B Normally you
I have two tables, Book and Tag , and books are tagged using the
We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType
I have two tables, both with start time and end time fields. I need
I have two tables containing Tasks and Notes, and want to retrieve a list
I have two tables in my database, called ratings and movies . Ratings: |

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.