Re: opening multiple databases from same program
Abel Birya <[email protected]> Sat, 10 Jul 2010 15:35:25 +0300
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
Hey. Thanks for the suggestion. I will look at the tools amd keep them in mind on future projects. The reason I decided to do my own scripts is that we had inherited a project from someone who had very poor db design skill. It had 7 tables with some having upwards of 60 fields which the script broke down to about 18 tables that really helped reduce the resources consumed. Kind regards. Abel. On 7/9/10, Hoang-Vu PHUNG <[email protected]> wrote: > If you want to migrate data from one database to another then it is better > to use the specific tool for that, for example scriptella or even db-unit. > > In oracle for example, we can have dblink and symbols so we can achieve the > same goal. Brief there are so many choices ! > > Just a small suggestion. > > Rgds > Vu > > > > --- En date de : Ven 9.7.10, Abel Birya <[email protected]> a écrit : > > De: Abel Birya <[email protected]> > Objet: Re: [SimpleORM] opening multiple databases from same program > À: [email protected] > Date: Vendredi 9 juillet 2010, 19h20 > > > > > > > > > > > > > > > > > > Hi, > > I had the same issue when I started using SimpleORM since I was doing a lot > of data migration scripts from one database to another. This is the strategy > that I used to achieve my goals; > > For example if I have an entity _User and I need to transfer it to another > db. I would name the corresponding entity User. I would then follow the > below procedure to achieve a seamless transfer process. > > > SSessionJdbc ses = SSessionJdbc. open(connection1 , "db1"); > ses.begin; > // create a method to retrieve users eg > List<_User> users = _User.getUsers( ses); > // detach the records into a dataset > > SDataSet ds = ses.commitAndDetach DataSet() ; > ses.close(); > > //retrieve the records from the dataset > users = ds.findAllRecords( _User.USER) ; // assuming that USER is the > SRecordMeta variable > > //open the new connection > > ses = SSessionJdbc. open(connection2 , "db2"); > > for(_User _user: users) { > ses.begin(); > //create the user on the other db and fill in the other variables such > as name etc > User user = ses.createWithGener atedKey() ; > > ses.commit() ; > } > > ses.close(); > > Hope this helps. > > Kind regards. > Abel > > In the even > > On Fri, Jul 9, 2010 at 7:02 PM, Franck Routier <franck.routier@ axege.com> > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi, > > > > well, AFAIK, you can't do that... ! > > > > SSessionJdbc has built-in checks that a connection is single threaded > > using a ThreadLocal object. [I think Hibernate has some kind of best > > practice to achieve the same goal (I'm not formal here, I didn't use > > hibernate for years)] > > > > There is only one dataSource per SSessionJdbc and one SSessionJdbc per > > thread. > > > > You could implement a different strategy to handle this part. Some work > > was done along this path in a previous version of Simpleorm, for using a > > single JTA transaction per session. But it is not maintained. > > See simpleorm/extras/ SConnectionEJB. java > > > > My question would be : what are you trying to achieve ? > > > > Franck > > > > Le vendredi 09 juillet 2010 à 17:11 +0200, Noel Grandin a écrit : > >> > >> Hi > >> > >> I'm opening multiple different databases from the same thread, which > >> is triggering this check: > >> > >> simpleorm.utils. SException$ Error: Thread's SSession already open [SS > >> 1.SkyMon] > >> [0@17:08:40. 976] !SE>: at > >> simpleorm.sessionjd bc.SSessionJdbc. innerOpen( SSessionJdbc. java:129) > >> [0@17:08:40. 976] !SE>: at > >> simpleorm.sessionjd bc.SSessionJdbc. open(SSessionJdb c.java:88) > >> [0@17:08:40. 976] !SE>: at > >> simpleorm.sessionjd bc.SSessionJdbc. open(SSessionJdb c.java:108) > >> > >> > >> What do I do? > >> > >> Thanks, Noel Grandin > >> > >> > >> > >> > >> > >> > >> > >> ____________ _________ _________ _________ _________ _________ _ > >> Disclaimer: http://www.peralex. com/disclaimer. html > >> > >> > >> > >> > >> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/SimpleORM/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/SimpleORM/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/