-->
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: Support for Temporary Tables
PostPosted: Fri Dec 31, 2004 2:06 pm 
Newbie

Joined: Tue Jul 20, 2004 5:42 pm
Posts: 2
Hello!
We have a scenario where the user can select multiple employeeID's that we need to show line items on in one shot. The number of items in the selection could possibly be 1000's. To execute such a query, we would have to use an IN clause e.g. SELECT name, date, salary FROM EMPLOYEE WHERE empID IN (x,y,z..........)

Now the IN length of the SQL will become very large & many databases have limits on the SQL statement length. We currently insert the selected mployee IDs into a temporary table & perform a JOIN with EMPLOYEE table to get the result set back. Can we do this using Hibernate? Are there any plan to support such a functionality?

Max Rydahl Andersen of JBOSS advised me to use createSQLQuery(), but I am not sure how that will solve the problem. The issue is that one cannot create tables on the fly in the database for every query being executed for a user, the database will be overwhelmed & that is not a scalable solution anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 31, 2004 2:21 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
The answer is to make a some kind of temporary table or tempaorary rows in a scratch table so that you can use IN with a sub-select. There are many ways to do this. Max is just suggesting a way that you can add the non-mapped temporary table to your Hibernate query.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 31, 2004 4:35 pm 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
Well, maybe then breakup your in clause to query say 500 id's at a time. and then combine the results from the iteration

- Shishir


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 31, 2004 11:16 pm 
Newbie

Joined: Tue Jul 20, 2004 5:42 pm
Posts: 2
Is this something is available in Hibernate? Can Hibernate create temporary table & manage it?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 01, 2005 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no (as i ave written to you before ,) - and how should/could it ?

temporary tables is something that is normally used when you have a query that is hard to otherwise make performant and often require special tweaking steps - not something that is easy to standardize, nor very usefull since its normally rather trivial with jdbc.

remember Hibernate is a ORM, not a low-level data manipulation tool (that is what you have jdbc and sql for)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 01, 2005 1:05 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
rajangupta wrote:
Is this something is available in Hibernate? Can Hibernate create temporary table & manage it?


Hibernate would be overkill for managing temporary tables. Just use JDBC.


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.