Re: Using database objects in different schemas
Re: Using database objects in different schemas
- Subject: Re: Using database objects in different schemas
- From: Chuck Hill <email@hidden>
- Date: Fri, 15 Dec 2017 20:42:45 +0000
- Thread-topic: Using database objects in different schemas
EOAdaptorChannel.Delegate.adaptorChannelShouldEvaluateExpression
boolean adaptorChannelShouldEvaluateExpression(EOAdaptorChannel channel,
EOSQLExpression expression)
Invoked from evaluateExpression to tell the delegate that the adaptor channel
object is sending expression to the database server. The delegate should return
true to permit the adaptor channel to send expression to the server. If the
delegate returns false, the adaptor channel does not send the expression and
returns immediately. When the delegate returns false, the adaptor channel
expects that the implementor of the delegate has done the work that
evaluateExpression would have done. The delegate can create a new
EOSQLExpression and send the expression itself before returning false.
Parameters:
channel - An adaptor channel object.
expression - The expression to be sent to the database server.
Returns:
true to permits the adaptor channel to send expression to the database
server.
See Also:
EOAdaptorChannel.evaluateExpression(EOSQLExpression expression), EOSQLExpression
On 2017-12-13, 1:06 AM, "Webobjects-dev on behalf of Markus Ruggiero"
<webobjects-dev-bounces+chill=email@hidden on behalf of
email@hidden> wrote:
André,
I seem to remember that there are hooks in WebObjects that allow you to
have a last look at the generated SQL statement before it is executed. You can
then fine tune your statements by adding the qualifiying schema name to any
table name. No need to fiddle with the EOModel.
EOAdaptor delegate something....
Chuck will certainly be able to give you more info to climb over that Hill
đ.
---markus---
> On 13 Dec 2017, at 08:10, André Rothe <email@hidden> wrote:
>
> Hello Jean,
>
> The problem with the "slave" accounts is, that I don't have the passwords
for them. So I cannot create a connection to every account except the "master"
account.
>
> Within the "master" there is a table, which holds the account names of
the "slaves". So it is possible to get the account names and build within the
database some queries like:
>
> sql := 'select * from' || get_a_slave_name() || '.table1';
> execute_immediate sql;
>
> But I need such a thing within WebObjects. I looked around in the API and
I found a theoretical solution, which I will try today.
>
> * get the "master" model (EOModel), it has a valid database connection
> * get the database context of that model
> * from the database context get:
> dc.availableChannel().adaptorChannel()
>
> * there is a method describeModelWithTableNames(tablenames), which
> creates an EOModel from the given tablenames
>
> Maybe it is possible, to set full-qualified tablenames there, so I could
build EOModels for every "slave" dynamically. The names of the "slaves" I can
get from my "master" account with a simple query (this table will be filled by
another application). Also I could rename the models, to get better access from
the defaultModelGroup (maybe the name of the "slave" account per model).
>
> The questions would be, whether or not the method above will accept
full-qualified table names, and whether or not the method is not an abstract
method for the Oracle database plugin.
>
> Best regards
> André
>
> Am 2017-12-13 00:40, schrieb Jean-François Veillette:
>> Hmmm ⊠reading your email a few times again, it seems that I didnât
>> understand your problem at first and that my answer was off-topic.
>> Iâm still not sure I really understand enough to be of any help, but
>> let me try again with (I hope) a better answer.
>> It seems that you would need a new jdbc connection to access the slave
DB.
>> As described in my previous email, you could create a new EOF stack,
>> listen for the notification to update the modelâs connection
>> dictionary, adjust it to connect to the desired slave DB, then use the
>> stack at will.
>> In hope that this is at least a closer attempts to answer your question,
>> jfv
>>> On Dec 12, 2017, at 10:49 AM, Jean-François Veillette
<email@hidden> wrote:
>>> You might need to create a new jdbc connection for every user.
>>> If I understand your situation correctly, I would try to use a unique
EOF stack for every session (user). In practice this can work well as long as
you donât have too many sessions (exhausting DB connection).
>>> You will have to change the âdelegateâ that updates the connection
dictionary so that it updates it specifically for the current user.
>>> This might sound more complicated than it really is, here is the 2
things you have to do (in short):
>>> 1- make sure you create a new EOF stack for every user:
>>> 2- Make sure the connection dictionary is correctly set for every new
stack
>>> Now in Detail:
>>> 1- make sure you create a new EOF stack for every user:
>>> I would user the pattern of a âProvider' to assist me in doing so:
>>> - create an editing context provider that will be responsible
for giving you EOEditingContext instances (letâs name it: ECProvider)
>>> - have provider to require arguments like the current userâs
id, or whatever you need to be able to set the correct connection dictionary.
>>> - give editing context from a new EOObjectStoreCoordinator
(new/specific EOF stack).
>>> 2- Make sure the connection dictionary is correctly set for every new
stack
>>> Improve with the provider created in step 1
>>> - the new stack will trigger the initialization of the database
connection dictionary (by way of NSNotification), the object responding to that
notification should be able to adjust the connection dictionary according to
the âcurrent userâ. You want to update the connection dictionary here, as part
of the notification dispatch.
>>> ps: Set a breakpoint on
âERXModelGroup.resetConnectionDictionaryInModelâ to better understand the
mechanism (this is the default method that will update the database connection
dictionary when a model is loaded in memory).
>>> ps: you can add yourself to receive such notification
by â NSNotificationCenter.defaultCenter().addObserver(this, aSelector,
EOModelGroup.ModelAddedNotification, null);â Note that If many objects receive
notification, the order is not predictable, so only one should be responsible
for updating the connection dictionary.
>>> ps: keep a cache of existing connection based on those users to avoid
opening too many connections to the DB as this will most likely be a problem.
>>> ps: find a way to close those connections when they are no longer
needed (when session dies)
>>> Every time you need a new EOEditingContext, ask ECProvider for it.
>>> If you use session default EC, set it from this provider, just so that
you can simply use session.defaultEditingContext later.
>>> Iâve never done this, but this is what I would try to achieve it.
>>> Hope this help,
>>> jfv
>>>> On Dec 12, 2017, at 5:59 AM, André Rothe <email@hidden>
wrote:
>>>> Hi,
>>>> I use an Oracle database, which has a "master" schema/account. This
aacount uses my Webobjects application. There are a lot of "slave"
schemas/accounts, which grant privileges on their own objects (tables, views
etc.) to the master. So the master can access these objects like:
>>>> select * from slave1.table1;
>>>> select * from slave2.table1;
>>>> The objects within the "slave" accounts are identical, so it could be
possible to use one EO model for all slaves.
>>>> How can I access these objects, if the master don't know the
user/password for every slave? I cannot change the credentials for the model
within the application without the passwords, but I have to change the source
of each object within a model to the specific slave before I execute any query.
Or should I use rawSQL?
>>>> I have no idea, how I could solve this with WebObjects. Is it possible
at all?
>>>> Best regards
>>>> André
>>>> _______________________________________________
>>>> 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