-->
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: Mapping a List or ScrollableResults to a Table.
PostPosted: Thu Feb 23, 2006 12:25 pm 
Newbie

Joined: Wed Feb 22, 2006 4:17 pm
Posts: 2
Hello,

I have all my data in a Collection (List) or I can also have them as ScrollableResults. I want to copy the data present in the List into a table in the Database (SQL Server 2000). I am using Myeclipse, Struts and Hibernate.

Let me describe what I am trying to do. I am trying to check for a particular condition and if the condition satisfies I am trying to copy the rows from the present tables to a new result table. I need a new result table for further review.

If I try doing it with using simple JDBC and SQL its simple. Since, I will have a ResultSet to operate on and can access each data element using getString() method and we can copy this to a new table. But this is not the case with Hibernate. I tried ScrollableResults() method, but dint work for me. Can anyone please help me with this?



Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 12:40 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If the data is already saved in the DB (in other modelled tables, the ones from which you got your results), you can use the new "insert into ... select ..." HQL syntax, new to Hibernate 3.1.

If you're using anything older than 3.1, or you're constained to using an in-memory list, then you'll have to insert each item in the normal way (create an object and save it). Judicious use of Session.flush() and jdbc.batch_size can help improve performance a little, but using JDBC directly will be better for this sort of operation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 11:57 am 
Newbie

Joined: Wed Feb 22, 2006 4:17 pm
Posts: 2
Thanks for the reply tenwit. I am using Hibernate 3.0 that is integrated with myeclipse IDE. I cannot save the data directly for the following reasons:

1. We are using a Rules Engine to determine the results and not a select statement. This is a research project, it has to be that way.

2. Also, in the result table I will have one more column thats a key that will be appended with the previous columns.

This is the reason why I was saving the data into a collection and then was trying to insert the data into the new table. Please suggest.

Thanks.


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.