That seems safe enough given when you are doing it but is slightly to somewhat 
more odious than the PlugIn subclass.



From: Paul Hoadley <[email protected]<mailto:[email protected]>>
Date: Friday, March 4, 2016 at 5:43 PM
To: Chuck Hill <[email protected]<mailto:[email protected]>>
Cc: WebObjects Development 
<[email protected]<mailto:[email protected]>>
Subject: Re: Can I force a reload of a database's JDBC info?

Hi Chuck,

I’ve also seen your post about subclassing JDBCPlugIn, which I’ll try shortly, 
but...

On 4 Mar 2016, at 5:31 pm, Paul Hoadley 
<[email protected]<mailto:[email protected]>> wrote:

On 4 Mar 2016, at 4:59 pm, Chuck Hill 
<[email protected]<mailto:[email protected]>> wrote:

Ah, right, protected, I was going to mention that and got distracted.  :-)  You 
will need to find a way to get it it to use a subclass of JDBCAdaptor.   Wonder 
does this with ERXJDBCAdaptor.

Here’s another potential hack. I know what the keypath 
‘jdbc2Info.typeInfo.citext’ should look like in the connection dictionary, 
because I can see it in there if I CREATE EXTENSION manually ahead of time. Can 
I just pre-emptively stick that in the connection dictionary at runtime if it’s 
not there? By which I mean I’ll try that—where and how would I do it? It 
doesn’t have to be in the migration.

As far as I can tell, this works. This is in a migration’s upgrade() method, 
after I CREATE EXTENSION and ALTER TABLE:

// Get the model
EOModel model = ERXModelGroup.defaultGroup().modelNamed("Ident");
// Get jdbc2Info dictionary from connectionDictionary
NSMutableDictionary<String, Object> overrides = ((NSDictionary<String, Object>) 
model
.connectionDictionary().valueForKey("jdbc2Info"))
.mutableClone();
// Build the value we want for the typeInfo.citext key
NSDictionary<String, Object> citext = NSPropertyListSerialization
.dictionaryForString("{defaultJDBCType = (\"OTHER\"); createParams = \"0\"; 
maxScale = \"0\"; minScale = \"0\"; isNullable = \"T\"; isSearchable = \"T\"; 
precision = \"0\"; }");
// Add the citext entry to overrides
overrides.takeValueForKeyPath(citext, "typeInfo.citext");
// Apply the overrides
EODatabaseContext.forceConnectionWithModel(model, overrides, editingContext);

Any comments on the safety/desirability of this approach, or where it sits on 
the scale of awful hacks?

Next up, PlugIn subclass.


--
Paul Hoadley
http://logicsquad.net/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to