-->
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: hibernate with sql
PostPosted: Fri Oct 27, 2006 2:29 am 
Newbie

Joined: Thu Oct 26, 2006 11:35 pm
Posts: 3
Location: India
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

_________________
Regards
Upendra


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 10:53 am 
Newbie

Joined: Wed Sep 20, 2006 2:57 pm
Posts: 16
Location: Encinitas, CA
My favorite link is here:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1538

It describes HQL which is a lot like SQL, but more powerful.

There's always multiple ways to do things in Hibernate. Once I have a Session, I have had good luck doing the following:

Code:
Query query = session.createQuery(hqlText);

// Really fast way to get row count:
ScrollableResults scrollableResult = query.scroll();
if (scrollableResult.last()) {
   rowCount = scrollableResult.getRowNumber() + 1;
}
else {
   rowCount = 0;
}
scrollableResult.close();



To get result set:
Code:
List list = query.list();


Before doing the above, you can use Hibernate's powerful pagination support like this:
Code:
query.setFirstResult(firstRowIndex);
query.setMaxResults(maxRowsToFetch);


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.