-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to handle temporary tables in hibernate
PostPosted: Tue Mar 07, 2006 9:03 am 
Beginner
Beginner

Joined: Fri Nov 18, 2005 5:49 am
Posts: 23
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:


Can any one pl let me know how to handle with temporary tables thro hibernate.

Regards

Seshadri


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 6:58 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
In what situation? Normally the matter doesn't crop up: temporary tables don't usually (and really shouldn't) survive long enough for hibernate to get involved. They should be created in a stored procedure, used in that stored procedure, then dropped in that same stored procedure. If you can explain what you're trying to do, I'll try to explain how to get hibernate to do it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 1:19 am 
Beginner
Beginner

Joined: Fri Nov 18, 2005 5:49 am
Posts: 23
Thanks for ur speedy response.

In our situation , we have to create a temporary table , insert some records into it and use those records.

For the time being, we have implemented like this
1. Obtain Hibernate Session.
2. Thro this session, obtain the JDBC connection
3. Execute the statement using JDBC statement

Is there any other better approach. Or pl let me this approach is ok.

Regards

Seshadri


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 4:41 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
That will work, and it's probably how I'd do it (if I had to). If your temporary table always has the same name, then you can map to it as normal, but you'll have to be careful about clearing the session cache when you drop the table (if anything tries to write to a table after it's dropped, something's going to get confused).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 09, 2006 1:17 am 
Beginner
Beginner

Joined: Fri Nov 18, 2005 5:49 am
Posts: 23
Thank you very much.


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