-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: problem with Hibernate and Lazy Loading
PostPosted: Thu Jun 12, 2008 6:59 am 
Beginner
Beginner

Joined: Mon Jan 07, 2008 4:13 am
Posts: 22
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


Top
 Profile  
 
 Post subject: Re: problem with Hibernate and Lazy Loading
PostPosted: Thu Jun 12, 2008 9:22 am 
Beginner
Beginner

Joined: Mon Jan 07, 2008 4:13 am
Posts: 22
and, all selects to DB generated by hibernate are correct.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.