-->
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: Copy table A to table B in schema S and Database D ?
PostPosted: Tue Mar 30, 2010 9:33 am 
Newbie

Joined: Tue Dec 22, 2009 11:52 pm
Posts: 10
I am trying to copy few rows of the data from that table into a new table (which has a new name but the same schema) from the same database.

How can we achieve this ?


Top
 Profile  
 
 Post subject: Re: Copy table A to table B in schema S and Database D ?
PostPosted: Tue Mar 30, 2010 11:34 am 
Regular
Regular

Joined: Thu May 07, 2009 5:56 am
Posts: 94
Location: Toulouse, France
SQL like:
insert into NEWTABLE (field1, ...) values (SELECT field1,... from OTHERTABLE where filter)

Hibernate Like:
query1 = session.createQuery("from OtherTable ");

rs = quey1.list();
//iterate on each object
NewTable obj = new NewTable ();
obj.setField1(nextgetField1())

session.save(obj);

caution: for batch processiong take a look at http://docs.jboss.org/hibernate/stable/ ... batch.html

_________________
everything should be made as simple as possible, but not simpler (AE)


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.