-->
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.  [ 6 posts ] 
Author Message
 Post subject: retreiving all of something
PostPosted: Thu Oct 25, 2007 4:22 pm 
Newbie

Joined: Thu Oct 25, 2007 3:37 pm
Posts: 17
If I want to retreive all of something, like all the users in the system, is there anyway to do this except for using a query?


Last edited by tomfrosty on Thu Oct 25, 2007 4:43 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 4:43 pm 
Newbie

Joined: Thu Oct 25, 2007 3:17 pm
Posts: 8
we have something like this in the dao layer - it uses an hql query:

public List findAll() {
log.debug("finding all Division instances");
try {
getSession().beginTransaction();
String queryString = "from Division";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 4:44 pm 
Newbie

Joined: Thu Oct 25, 2007 3:37 pm
Posts: 17
so, you HAVE to use a query here?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 4:47 pm 
Newbie

Joined: Mon Apr 30, 2007 12:27 pm
Posts: 18
1 . - Criteria criteria = session.createCriteria(User.class)
criteria.list();

2 . - Query query = session.createQuery("from user");
query.list();


I think chapter 14 (not too sure) is all about querying, maybe you should skip to that one.

Not to sure about the code either, I just wrote it from the top of my head.

cheers


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 4:49 pm 
Newbie

Joined: Thu Oct 25, 2007 3:17 pm
Posts: 8
if you have a users table, I'm not sure how you would get the data without a query to the database, if the data is in your database the answer is yes, it could be cached if you have already retrieved it but you will still have to ask/query hibernate for it, which may or may not cause a query to your database


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 4:50 pm 
Newbie

Joined: Thu Oct 25, 2007 3:37 pm
Posts: 17
moving to dublin,

I just found that , but thanks anway. I gave you a credit too, cuz you got less than I do.


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