RE: EOF and Oracle
RE: EOF and Oracle
- Subject: RE: EOF and Oracle
- From: "Jonathan Fleming" <email@hidden>
- Date: Mon, 22 Dec 2003 06:12:32 +0000
From: "Jonathan D. George" <email@hidden>
To: email@hidden
Subject: EOF and Oracle
Date: Sun, 21 Dec 2003 14:38:07 -0600
Hello,
For our application we use Oracle's internal security, in that each user
has their own Oracle username/password. There are multiple schemas within
the application, and thus the schema id must be prepended to each table
name in the SQL queries.
My question is.. . how do I programatically set the schema id for the EOF
connection dictionary?
Um, why exactly do you want to do that? Are you tying in with some
bizarre legacy system?
Life is generally much simpler if you think of your app as the database
user. Unless you have some wierd legacy requirement, your individual
users shouldn't need to access the database directly. As a general rule,
giving a mere user direct access to your database schema is
(...shudder...) a really bad idea. They should not even have their own
individual logins to the database; therefore, you should not even be
trying what you are proposing. If you want them to login, you should have
that behavior controlled by the app, so that they login to the app.
Their access to the database is then restricted by the app.
A good way to think of things is that one Oracle user = one database
schema. Therefore, if you tell your app to login as "test", it will login
to your test schema. If you tell your app to login as "deployment", it
will login to your deployment schema. Hopefully, you have another
user named "development" that exists in a completely seperate
database, not just a seperate schema. This lets developers change the
schema on the development database without risking negative impact on the
test or deployment databases.
Doing things this way can yield some significant benefits. Of course, if
you have legacy requirements, you're kind of stuck...
Any advice on this would be greatly appreciated!
Ok.... refering to the "Setting the Connection Dictionary Programmatically"
section of the EOF developers guide which states:
1) Insert the connection information into an NSDictionary object using
adaptor-defined keys.
2) Assign the dictionary to the adaptor using the EOAdaptor method
setConnectionDictionary.
3) Verify that the connection dictionary is valid using the EOAdaptor method
assertConnectionDictionaryIsValid.
The documentation doesn't say much after this, but this is what you could
try:
Here is what you could do in your Session's constructor:
public Session(){
super();
// changing database-connection to appropriate database (from
NSUserDefaults)
NSUserDefaults defs = NSUserDefaults.standardUserDefaults();
String serverId = (String) defs.objectForKey("DBServer");
String userName = (String) defs.objectForKey("DBLogin");
String password = (String) defs.objectForKey("DBPassword");
NSMutableDictionary dict = new NSMutableDictionary();
if (serverId !=null && userName !=null && password !=null) {
dict.setObjectForKey(serverId,"serverId");
dict.setObjectForKey(userName,"userName");
dict.setObjectForKey(password,"password");
} else {
WOApplication.logString("Tools.getDBConnectionDictionary:
db-infos not present");
dict = null;
}
if (dict!=null) EOUtilities.connectWithModelNamed(
defaultEditingContext(), "YourModelName", dict);
}
or you could forget all that and just use these 3 lines in your session or
application constructor:
EOModel model;
model = EOModelGroup.defaultGroup().modelNamed("MyModel");
model.setConnectionDictionary(connectionInfo);
Hope that help yer Jonathan
Jonathan F :^)
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.