Re: Dynamically altering external names for Entities (solution)

Chuck Hill <[email protected]> Mon, 12 May 2003 14:37:44 -0700
Newsgroups gmane.comp.web.webobjects.eof
Organization Global Village Consulting, Inc.
Message-ID <[email protected]>
Maybe I'm missing something.  Are you creating an EOF stack per 
session?  Otherwise all sessions will share the channels and only the 
last session created will get the delegate call.


Chuck


Mark Morris wrote:
> Thanks for the help. After looking into it some more, I don't think in my case I'll need the flexibility offered by Eric's suggestion, as my requirements are a bit more bounded.  Here's my (mostly tested) plan, which basically alters the SQL just before it gets executed:
> 
> In the Application constructor, I'll go through each EOModel in the default EOModelGroup. If an entity has a specific userInfo key set, I'll replace the variable portion of the external name with a placeholder string I'm certain won't be in a real table name.
> 
> In the Session constructor, I'll instantiate a delegate for EOAdaptorChannel, implementing adaptorChannelShouldEvaluateExpression.  I'll register for the EODatabaseContext.DatabaseChannelNeededNotification, so I can set the delegate for any channels that might get created.
> 
> My delegate method will just be:
> 
>   public boolean adaptorChannelShouldEvaluateExpression(
>                        EOAdaptorChannel channel, EOSQLExpression expression ) {
>      String statement = expression.statement().replaceAll( placeHolderString, tableNameSuffix );
>      expression.setStatement( statement );     
>      return true;
>   }
>  
> I'll have a Session method that will update the "tableNameSuffix" (and invalidate all objects).
> 
> In limited testing, this seems to do what I want, which is to just model one "set" of all the repeating entities, and allow me to deal with them one "set" at a time.  Please let me know if anyone see's any potential gotchas in this approach.  ;-)
> 
> Thanks for the input!
> 
> -- Mark
> 
> _______________________________________________
> EOF mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/eof


-- 

Chuck Hill                                 [email protected]
Global Village Consulting Inc.             http://www.global-village.net

Progress is the mother of all problems.
- G. K. Chesterton