• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: model connections to multiple DBs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: model connections to multiple DBs


  • Subject: Re: model connections to multiple DBs
  • From: Anjo Krank <email@hidden>
  • Date: Mon, 04 Apr 2011 17:30:47 +0200

Please keep this on-list.

I haven't actually tried it and don't know what you mean by "overhead", but the core idea would be sth like:

public Session() {
   EOModelGroup modelGroup = new EOModelGroup();
   EOModel model = modelGroup.addModelWithPath("/some/where"); // model should be in a subfolder of "Resources" so it won't get loaded
   adjustConnectionDict(model);
   EOAdaptor adaptor = EOAdaptor.adaptorWithModel(model);
   EODatabaseContext dbc = new EODatabaseContext(adaptor);
   EOObjectStoreCoordinator osc = new EOObjectStoreCoordinator();
   osc.addCooperatingObjectStore(dbc);
   EOEditingContext ec = new EOEditingContext(osc);
   setDefaultEditingContext(ec);
}

This probably won't even compile, but should get you started. All other ECs must be created as

 new EOEditingContext(session().defaultEditingContext().parentObjectStore())

or from a thread-local.

Cheers, Anjo


Am 04.04.2011 um 17:17 schrieb Michael Gargano:

> This sounds good to me.  :-D  Two questions... how much overhead is this?  (as i'm sure this is not a light weight process)  where do i find out how to dynamically create new eof stacks?
>
> Thanks.
> -Mike
>
>
> On Apr 4, 2011, at 11:11 AM, Anjo Krank wrote:
>
>> Actually, it's a yes.
>>
>> You can create one EOF stack per user and clone the model group so it's used in that stack. Then adjust the model dict for the connection and you're good to go. You need to take really good care you never use EOModelGroup.defaultGroup() anywhere, though.
>>
>> Cheers, Anjo
>>
>> Am 04.04.2011 um 17:04 schrieb Simon:
>>
>>> i think it's a big no :-(
>>>
>>> but you can definitely have multiple models - one for each db - and
>>> relationships between the models.
>>>
>>> simon
>>>
>>> On 4 April 2011 16:00, Michael Gargano <email@hidden> wrote:
>>>> Hi all,
>>>>
>>>>      Is there a way to have a model connect to different databases simultaneously?  So, I have a schema that is rev. eng'ed but that same schema is on 10 different databases, I want to fetch data from different DB's for different users of the system simultaneously.  Is this possible?  omg.... please say YES.  :)
>>>>
>>>> Thanks.
>>>> -Mike
>>>>
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list      (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>>
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: model connections to multiple DBs
      • From: Michael Gargano <email@hidden>
References: 
 >model connections to multiple DBs (From: Michael Gargano <email@hidden>)
 >Re: model connections to multiple DBs (From: Simon <email@hidden>)
 >Re: model connections to multiple DBs (From: Anjo Krank <email@hidden>)

  • Prev by Date: Re: model connections to multiple DBs
  • Next by Date: Re: model connections to multiple DBs
  • Previous by thread: Re: model connections to multiple DBs
  • Next by thread: Re: model connections to multiple DBs
  • Index(es):
    • Date
    • Thread