-->
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.  [ 1 post ] 
Author Message
 Post subject: partial/manual fetch child records in simple Set
PostPosted: Fri Jul 08, 2005 7:06 am 
Newbie

Joined: Fri Jul 08, 2005 5:20 am
Posts: 1
Help me, please!
mapping:
<hibernate-mapping
package="hb3">

<class name="ClientM1" table="Clients" lazy="true">

<id name="id" type="long">
<generator class="native"/>
</id>
<property name="name" type="string" length="30" />

<set name="phonesset">
<key column="client_id"/>
<one-to-many class="Phone"/>
</set>
</class>

<class name="Phone">
<id name="idphone">
<generator class="native"/>
</id>
<property name="Phone" type="string"/>
<property name="Ph_type" type="short"/>
</class>


</hibernate-mapping>


now - a insert 1 record in ClassM1 table and 10001 records in Phone table

next - im try get my recors manualy - by 1 per cicle. but!:

long id=1;
ClientM1 c1= (ClientM1) session.load(ClientM1.class,new Long(id));
Phone ph1;
for(Iterator tt=c1.getPhonesset().iterator(); tt.hasNext();)
{
/* select clientm1x0_.id as id0_, clientm1x0_.name as name0_0_ from Clients clientm1x0_ where clientm1x0_.id=? */
/* select phonesset0_.client_id as client4_1_, phonesset0_.idphone as idphone1_, phonesset0_.idphone as idphone0_, phonesset0_.Phone as Phone1_0_, phonesset0_.Ph_type as Ph3_1_0_ from Phone phonesset0_ where phonesset0_.client_id=? */
/*
in this statement hibernate read all set - (fetch all records from Phone)
by use opened second select
*/
/* on this poin - all record already rean into Set */
ph1=(Phone)tt.next();
System.out.println(ph1.getPhone());
System.out.println(c1.getPhonesset().size());
/* output -10001 */
}


But im need fetch 1 record by 1 cycle.
How do it?
Thsnks!

PS: use
<set name="phonesset" lazy="false" fetch="select" >
<key column="client_id" />
<one-to-many class="Phone"/>
</set>
with fetch= any right value ("select, subselect and join)
and
<property name="hibernate.max_fetch_depth">2</property>
<property name="hibernate.default_batch_fetch_size">4</property>
<property name="hibernate.jdbc.fetch_size">10</property>
dont have effect ....


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

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.