Hi Guys,
Really odd one here. I have an object called POF that contains a List collections called lineItems. The constructor of POF initializes lineItems = new ArrayList(0);
I have 1 POF in my database with 1 LineItem object persisted in its collection.
When I am loading the POF out, when I print the size of the collection, there is a NULL object in there rather than just the 1 LineItem.
I have run the Hibernate SQL directly on the database and only 1 row comes back for the POF query AND for the LineItem collection fetch.
I do not understand why a NULL object is being stored in my list. I am debugging the POF object and finding the null line item element straight after the load with Hibernate, i.e nothing else is accessing the line item collection.
Your assistance appreciated.
Hibernate version:
2.1.4
Mapping documents:
N/A
Code between sessionFactory.openSession() and session.close():
Code:
Query q = session.createQuery(
"from POF as p " +
" left outer join fetch p.lineItems " +
"where p.id = :pofId"
);
q.setParameter("pofId", id);
pof = (POF) q.list().get(0);
Full stack trace of any exception that occurs:N/A
Name and version of the database you are using:SQL Server 2000
The generated SQL (show_sql=true):Code:
Hibernate: select pof0_.pof_id as pof_id0_, lineitems1_.line_item_id as line_ite1_1_, pof0_.created as created0_, pof0_.status as status0_, pof0_.reference as reference0_, pof0_.external_id as external5_0_, pof0_.originator as originator0_, pof0_.originator_full_name as originat7_0_, pof0_.department as department0_, pof0_.department_code as departme9_0_, pof0_.currency_code as currenc10_0_, pof0_.tax_rate as tax_rate0_, pof0_.authoriser as authoriser0_, pof0_.authoriser_full_name as authori13_0_, pof0_.applies_to_min as applies14_0_, pof0_.applies_to_max as applies15_0_, pof0_.net_cost as net_cost0_, pof0_.discount_cost as discoun17_0_, pof0_.carriage_cost as carriag18_0_, pof0_.tax_cost as tax_cost0_, pof0_.gross_cost as gross_cost0_, pof0_.notes as notes0_, pof0_.supplier_id as supplie22_0_, pof0_.delivery_address_id as deliver23_0_, lineitems1_.code as code1_, lineitems1_.description as descript3_1_, lineitems1_.fn as fn1_, lineitems1_.quantity as quantity1_, lineitems1_.unit_price as unit_price1_, lineitems1_.tax_type as tax_type1_, lineitems1_.net_cost as net_cost1_, lineitems1_.notes as notes1_, lineitems1_.pof_id as pof_id1_, lineitems1_.line_item_id as line_ite1___, lineitems1_.pof_id as pof_id__ from dbPOF.dbo.tbl_POFs pof0_ left outer join dbPOF.dbo.tbl_LineItems lineitems1_ on pof0_.pof_id=lineitems1_.pof_id where (pof0_.pof_id=? )
Debug level Hibernate log excerpt: