This was accidentially posted on NHibernate forum, but it should have been on Hibernate users form:
I have a question concerning how and where to initialize an array in Hibernate 3.
I will have an array of objects instead of java collection
interfaces. Somehow I got a very huge array, with the expected
not-null elements at the end of the array. All other elemtns are NULLs.
Here is the tables:
create table main_table (id number(9) not null, constraint main_pk
primary key (id));
create table sub_table (id number(9) not null, main_id number(9) not
null, constraint sub_pk primary key (id), constraint sub_fk foreign key
(main_id) references main_table (id));
I populated three rows of records on sub_table, with all main_id values
pointing to the primary key of the main_table.
here is the hibernate mapping file:
<array name="subs" cascade="all">
<key column="main_id" />
<list-index column="id" />
<one-to-many class="Sub" />
<array>
but when I called something.getSubs(), I got a very huge (over 2000) array,
only the last three elements were what I populated and expected.
I heard Hibernate array mapping is not as solid as collection interface
mapping. Is that because Hibernate array mapping unables to initialize a correct
length at run-time? Is there any work around on array mapping?
|