Hello,
When an array is made persistent, hibernate generates an extra table for the array's content. E.g:
Code:
@Entity class A {
@Id int id;
B b;
}
@Embeddable class B {
@CollectionOfElements @IndexColumn(name="arrayIndex") C[] c;
}
@Embeddable class C {
String bla;
}
I create an instance of A where A.b is null and persistify this instance. The extra table has no content and the b column of the A table is null - fine
However, when I try to retrieve the A member instance, hibernate creates the A.b instance with an empty collection. How can this be avoided?
The hibernate debug log contains:
Code:
2009-03-20 10:50:27 DEBUG: loading collection: [A.B.c#testId]
2009-03-20 10:50:27 DEBUG: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2009-03-20 10:50:27 DEBUG:
select ...
2009-03-20 10:50:27 DEBUG: about to open ResultSet (open ResultSets: 0, globally: 0)
2009-03-20 10:50:27 DEBUG: result set contains (possibly empty) collection: [A.B.c#testId]
2009-03-20 10:50:27 DEBUG: about to close ResultSet (open ResultSets: 1, globally: 1)
2009-03-20 10:50:27 DEBUG: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2009-03-20 10:50:27 DEBUG: 1 collections were found in result set for role: A.B.c
2009-03-20 10:50:27 DEBUG: collection fully initialized: [A.B.c#testId]
2009-03-20 10:50:27 DEBUG: 1 collections initialized for role: A.B.c
2009-03-20 10:50:27 DEBUG: done loading collection
Thank you,
Robert