Hi ,
I have problem with hibernate and lazy-loading of collections. i have object Person (1 record in table PERSON) and 2 objects address (2 rows in table ADDRESS).
person.hbm.xml:
Code:
<list cascade="all" inverse="true" name="addressList">
<key column="person_id" on-delete="cascade"/>
<list-index column="id"/>
<one-to-many class="sk.xxxx.Address"/>
</list>
Person.java:
Code:
private List<Address> addressList = new ArrayList<Address>();
in address.hbm.xml:
Code:
<many-to-one class="sk.xxxx.Person" column="person_id" name="person"/>
Address.java:
Code:
...
private Person person;
...
when i load (load by id) person object from database (i use Spring, Spring MVC and openSessionInViewInterceptor):
in person.getAddressList() i have for example 13456 items (i don`t understand why 13456, in address table in DB there are 400 records).
i have 2 address to my person - last address object is in the last position of list, when person.getAddressList() is 13456, last item from DB is person.getAddressList().get(13455), but i don`t know where is next item ( i have 2 address to this person), because all (?) next items are null objects. in debug mode of my application i see person.getAddressList() is PersistentList.
please, where is problem, why i have size of mu addressList so too large, and where are my objects ?
i use hibernate Hibernate-Version: 3.2.5.ga and bea weblogic 9.2.2.
thanks!
Ivan