Re: opening multiple databases from same program

Abel Birya <[email protected]> Sat, 10 Jul 2010 12:18:22 -0700
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Hey,

The reason why I felt it was best to have my own scripts at the time is
because we had inherited a project which had a very poorly designed db with
some tables having up to upwards of 60 fields. We were able to break them
them down from 7 to about 19 tables with leaner entities which greatly
reduced the resource intensiveness of the app.

Thanks for the suggestion anyway. Haven't had a look at the tools yet but I
shall keep them this in mind for future projects.

Kind regards.
Abel

Thanks for the suggestion. Haven't had a look at the tools yet but I shall
keep them this in mind for future projects.

On Fri, Jul 9, 2010 at 12:43 PM, 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<http://mc/[email protected]>
> > 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<http://www.peralex.com/disclaimer.html>
>> >
>> >
>> >
>> >
>> >
>>
>>
>
>  
>