-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to get all record's number
PostPosted: Thu Sep 04, 2003 8:39 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
question one

for example , i have 100 records, every page show 10 records

Code:
q=session.createQuery(hql);
q.setFirstResult(firstResult);
q.setMaxResults(10);


the code only get the record and record number on every page,how to get all record's number

if i need

Code:
q=session.createQuery(hql);


run the code again to get the total record number?



question two
i set lazy=true, for example , i load the parent on one session,but in another session,i need use
Code:
parent.getchilds().add(child)
to add a child, it will throw error, so i have to in first session to load every parent's child


now in first session,i use code
Code:
for(Iteator ite=parent.getchild().iterator;ite.hasnext()){
ch=(child)ite.next();
}



i don't know whether have other ways or not.

please give me some advice on it! thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 8:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
one:
yes

two:
If using 2.1, use the session.lock( parent ) method in the second session to associate that parent to that second session.
Code:
session.lock( parent );
parent.getChilds().add( child );
...

Otherwise, use
Code:
session.update( parent );
parent.getChilds().add( child );
...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 9:37 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
steve , thanks

i know how to do it


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.