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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:29:51+00:00 2026-05-15T21:29:51+00:00

I have inherited a bit of Java code that uses Hibernate. Some of the

  • 0

I have inherited a bit of Java code that uses Hibernate. Some of the people using this code are now reporting that they are getting NullPointerExceptions all over the place.

I’ve been able to track this down and found that when we execute a query that pulls a list of objects from the database, that has a list of objects (that get pulled from a different table) Hibernate seems to be leaving holes in the list (NULL values). So the list may look something like:

Object
Object
NULL
Object

The code we are using to pull the information out of the database is:

List<PrinterGroup> groups = 
    this.getSession().createQuery( "from PrinterGroup" ).list();

And then inside each PrinterGroup is a list of Filters that have the NULL values in them.

While I could go around and find every instance were we loop over this list and add a NULL check I feel it is a bandaid fix, and there has to be a way to tell Hibernate to not pull null values in.

EDIT:

  • We are using Hibernate 3.2.2

EDIT2:

So the database seemed to be confusing. The PrinterGroup -> Filter relationship is a one to many relationship. So PrinterGroups have a list of filters. The problem is that list of filters has null values in it when it comes out of the database (There are no null values in the database by the way) and the list comes out looking like above.

EDIT3:

Here is the mapping relavant picese in the PrinterGroup HBM

<subclass name="PrinterGroup" discriminator-value="PG">
   <list name="filters"
              lazy="true"
              table="PG_FILTER"
               inverse="false"
                cascade="all-delete-orphan">

        <key>
           <column name="PG_ID" not-null="false"/>
        </key>
        <index column="LISTPOSITION"/>
        <one-to-many class="Filter"/>
     </list>

And the Filter is a pretty basic POJO 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-15T21:29:52+00:00Added an answer on May 15, 2026 at 9:29 pm

    Is this collection mapped with a <list> (or other indexed collection) and <list-index>?

    All collection mappings, except those with set and bag semantics, need an index column in the collection table. An index column is a column that maps to an array index, or List index, or Map key. … The index of an array or list is always of type integer and is mapped using the element. The mapped column contains sequential integers that are numbered from zero by default.

    I would imagine that when using an indexed collection, if your index column has gaps in it (i.e. it has values like 0, 1, 3, 7) that Hibernate would populate the resulting List with empty elements at the expected places.

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

Sidebar

Related Questions

I have inherited some legacy PHP code what was written back when it was
I have inherited a project that uses LLBLGen Pro for the DB layer. The
I have a bit of code that I have been tasked with converting to
Good afternoon, I inherited some C# code from years ago. I have refactored it
I have inherited a VB6/Access application that we have developed and sold for many
I have inherited a poorly written web application that seems to have errors when
We have inherited an ant build file but now need to deploy to both
I have inherited a load of VB6 code which has tons of individual OCX
I am using SQLite in a Java application through Zentus . In this context
I have this class model where, Bank is a class which is now going

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.