0

This is a very tricky issue. I'm using hibernate 3.6.8 and using hbm xml mappings. I has a case of a one to many relation that ends up in an array with null values. I read documentation on this about having indexes and such, but when I look into the database to the object that causes this, everything seems fine. My hbm mapping looks like this.

<array name="child"
        element-class="childClass"
        table="childTable" fetch="join">
        <key>
            <column name="parentColumnId" />
        </key>
        <list-index column="idx" />
        <one-to-many class="childClass" />
    </array>

I get an array with 4 null values and on the database I find 6 records (for this parent), all of them with sequencial idx values (0,1,2,3,4,5)

I'm a bit lost here. Any help?

(More info)

The business object model is huge, and I'm getting this issue in a relation that stands in the middle of the business object model tree. it's something like:

...
public class Parent {
    private Child[] allChild;
}
...

I'm using detached criteria to obtain the object from the DB. The criteria targets other objects in the BOM tree that not the ones causing the trouble here. I'm also using CriteriaSpecification.DISTINCT_ROOT_ENTITY to obtain distinct objects.

Another interesting fact is that, it doesn't happen every time. Sometimes it returns the array totally populated, without nulls. Still didn't figure out what's different. Since this started to happen on automated tests, the execution is always the same..

cattox
  • 177
  • 2
  • 16
  • Please elaborate that how are you getting the array and how you get into the problem. Also how is it related to your database table that has 6 rows. – sjain Apr 30 '15 at 17:27
  • The "Child" database table has 6 rows related to the "Parent". And everything looks fine there.. Hope this new info rings a bell on anyone. Please point out any other info that I might have forgotten to mention. – cattox May 02 '15 at 14:18

0 Answers0