Re: multiple model usage example
Re: multiple model usage example
- Subject: Re: multiple model usage example
- From: "Joe Little" <email@hidden>
- Date: Mon, 28 Jul 2008 13:22:19 -0700
On Mon, Jul 28, 2008 at 1:04 PM, Joe Little <email@hidden> wrote:
> On Mon, Jul 28, 2008 at 12:57 PM, Kieran Kelleher <email@hidden> wrote:
>> Yes. You are correct. It knows which database to get each entity from based
>> on the connection dictionary of the model to which the entity belongs. You
>> don't have to do anything except put the models in your app and/or
>> frameworks. Even without Wonder, that is how EOF treats multiple eomodels.
>> Wonder allows more flexibility in terms of multiple eomodels, IIRC, with
>> possibility to define different prototypes for each eomodel and different
>> database vendors for each model and allows you to set eomodel load order
>> which is important to make sure that prototype entities are loaded before
>> the entities that refer to those protos.
>>
>
> There is a lot written on the fact that you can load multiple models,
> and they refer to modelgroups and above people remark on how to set
> the dictionary and manually connect up your adaptor. It sounded like
> there is a lot of missing pieces, and not that it is just done
> automatically. I thought I had to get the adaptor channel, define each
> model, assign the right dictionary to each model, and then somehow
> differentiate a fetch in code specific to each model. That was where
> the cookie crumbs were leading me to.
>
>
and it just works.. Thanks to all for the group enlightenment.
>> On Jul 28, 2008, at 3:42 PM, Joe Little wrote:
>>
>>> On Mon, Jul 28, 2008 at 11:37 AM, Kieran Kelleher <email@hidden>
>>> wrote:
>>>>
>>>> Joe,
>>>>
>>>> OK, I see where you are going ... you are wondering how to fetch against
>>>> a
>>>> different eomodel ....... well, stop wondering ... it is automagic!
>>>>
>>>> The only restriction for having lots of eomodels is that *all* entity
>>>> names
>>>> must be unique! (Note the java class package.name and database table
>>>> names
>>>> can be whatever you want)..... everything in EOF then "just works".
>>>>
>>>> Regards, Kieran
>>>>
>>>>
>>>> PS. That code was in my Application constructor .... but may be
>>>> irrelevant
>>>> to your questions .... I was just showing how you could access models and
>>>> entities after super in App constructor since Wonder has already loaded
>>>> them
>>>> all at that stage.
>>>>
>>>>
>>>
>>> I think you get where I'm going. If its all unique (which it is in my
>>> combined models) my guess is that EOF will know where to pull what
>>> entity from which database. So, doing something like this:
>>>
>>> public NSArray getApplicants () {
>>> return EOUtilities.objectsForEntityNamed (new
>>> EOEditingContext(),
>>> "Applicants");
>>> }
>>>
>>> public NSArray getArchApplicants () {
>>> return EOUtilities.objectsForEntityNamed (new
>>> EOEditingContext(),
>>> "ArchApplicants");
>>> }
>>>
>>> would work without even playing with the models and constructor
>>> definitions, as its done automatically, at least in Wonder
>>> Applications/Frameworks. Is that correct? The above come from two
>>> separate models.
>>>
>>>
>>>
>>>> On Jul 28, 2008, at 2:18 PM, Joe Little wrote:
>>>>
>>>>> On Mon, Jul 28, 2008 at 11:03 AM, Kieran Kelleher <email@hidden>
>>>>> wrote:
>>>>>>
>>>>>> Hi Joe,
>>>>>>
>>>>>> AFAIK, if you just define properties below for each model using the
>>>>>> syntax
>>>>>> <modelname>.URL, <modelname>.DBUser, etc., all the models and their
>>>>>> entities
>>>>>> will be automatically loaded at startup by Wonder which checks for such
>>>>>> properties at startup.
>>>>>>
>>>>>> In your Application constructor, after super(), all the models and
>>>>>> entities
>>>>>> will have been loaded by Wonder, so you can iterate thru models and/or
>>>>>> entities and do what you like with them, for example ......
>>>>>>
>>>>>> // Make demography eomodel readonly
>>>>>> boolean demographyIsReadOnly =
>>>>>> ERXProperties.booleanForKeyWithDefault("demography.isReadOnlyEntities",
>>>>>> false);
>>>>>>
>>>>>> if (demographyIsReadOnly) {
>>>>>>
>>>>>> EOModel demography =
>>>>>> EOModelGroup.defaultGroup().modelNamed("demography");
>>>>>>
>>>>>> for (java.util.Enumeration demographyEntityEnumerator =
>>>>>> demography.entities().objectEnumerator(); demographyEntityEnumerator
>>>>>> .hasMoreElements();) {
>>>>>> EOEntity entity = (EOEntity)
>>>>>> demographyEntityEnumerator.nextElement();
>>>>>> entity.setReadOnly(true);
>>>>>> }
>>>>>>
>>>>>> }
>>>>>
>>>>> So, I presume you'd want ERXModelGroup there. The above was not in
>>>>> Application.java I presume. When asking for a objects for a specific
>>>>> entity, has done one use the usual utilities to call on the specific
>>>>> model?
>>>>>
>>>>> ie.. NSArray items = EOUtilities.objectsForEntityNamed (new
>>>>> EOEditingContext(), "Item");
>>>>>
>>>>> I guess I'm only missing the link between auto-loaded models and the
>>>>> above style call, which I did with this:
>>>>>
>>>>> admitModel = ERXModelGroup.defaultGroup().modelNamed("admit");
>>>>> admitArchModel = ERXModelGroup.defaultGroup().modelNamed("admitarch");
>>>>>
>>>>> Does it just look for an Item across both models?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Kieran
>>>>>>
>>>>>> On Jul 28, 2008, at 1:38 PM, Joe Little wrote:
>>>>>>
>>>>>>> On Mon, Jul 28, 2008 at 5:08 AM, Kieran Kelleher
>>>>>>> <email@hidden>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi Joe,
>>>>>>>>
>>>>>>>> Not sure if this is what you are looking for .... here is an example
>>>>>>>> of
>>>>>>>> entries in Properties for access to different databases:
>>>>>>>>
>>>>>>>> <snip>
>>>>>>>>
>>>>>>>>
>>>>>>>> #########################################################################
>>>>>>>> # ERExtensions - ERXModelGroup properties
>>>>>>>>
>>>>>>>>
>>>>>>>> #########################################################################
>>>>>>>>
>>>>>>>> er.extensions.ERXModelGroup.prototypeModelNames=WKPrototypes
>>>>>>>>
>>>>>>>> cheetah.URL = jdbc:mysql://host1/cheetah?capitalizeTypenames=true
>>>>>>>> cheetah.DBUser = @@cheetah.dbuser@@
>>>>>>>> cheetah.DBPassword = @@cheetah.dbpassword@@
>>>>>>>> cheetah.DBDriver =
>>>>>>>> cheetah.DBPlugin =
>>>>>>>> cheetah.DBJDBCInfo =
>>>>>>>>
>>>>>>>>
>>>>>>>> demography.URL =
>>>>>>>> jdbc:mysql://host2/demography?capitalizeTypenames=true
>>>>>>>> demography.DBUser = @@demography.dbuser@@
>>>>>>>> demography.DBPassword = @@demography.dbpassword@@
>>>>>>>> demography.DBDriver =
>>>>>>>> demography.DBPlugin =
>>>>>>>> demography.DBJDBCInfo =
>>>>>>>> </snip>
>>>>>>>>
>>>>>>>> IIRC, ERXModelGroup is where a lot of model startup entity loading
>>>>>>>> munging
>>>>>>>> happens, so examining the source there can indicate what is
>>>>>>>> happening,
>>>>>>>> how
>>>>>>>> it works, and what Properties entries affect what.
>>>>>>>>
>>>>>>>
>>>>>>> I'll look into the code. Never looked inside Wonder source and was
>>>>>>> hoping for examples on how to use it. So, there isn't posted anyway
>>>>>>> examples on using ERXModelGroup and loading models into an app within
>>>>>>> Application? Again, I've been limited to the stuff that WO just gives
>>>>>>> you to date, which is all automatic. My understanding currently ends
>>>>>>> there.
>>>>>>>
>>>>>>>
>>>>>>>> HTH,
>>>>>>>>
>>>>>>>> Kieran
>>>>>>>>
>>>>>>>> On Jul 28, 2008, at 2:22 AM, Joe Little wrote:
>>>>>>>>
>>>>>>>>> That would need to be an ER Model I take it. Again, do you happen to
>>>>>>>>> have a snippet of code taking multiple entity modeler defined
>>>>>>>>> models,
>>>>>>>>> overriding those settings, etc, and then having a joined model
>>>>>>>>> group..
>>>>>>>>> or should this not be in a model group. I'm confused as to how this
>>>>>>>>> is
>>>>>>>>> all done w/ Wonder as I've also been trying to use ModelConnector
>>>>>>>>> and
>>>>>>>>> other PracticalWO Frameworks solutions to the same.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sun, Jul 27, 2008 at 10:48 PM, Guido Neitzer <email@hidden>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> On 27.07.2008, at 23:28, Joe Little wrote:
>>>>>>>>>>
>>>>>>>>>>> Ok. I've banged my head on this one a lot. ConfigurationManager
>>>>>>>>>>> allows
>>>>>>>>>>> you to change anything except for the database itself.
>>>>>>>>>>
>>>>>>>>>> ??
>>>>>>>>>>
>>>>>>>>>> dbConnectURLGLOBAL=jdbc:postgresql://localhost/meetings
>>>>>>>>>>
>>>>>>>>>> That can also be set on a per model base.
>>>>>>>>>>
>>>>>>>>>> cug
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> http://www.event-s.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> 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