Thanks, Ramsey, I am fully aware of this. It is very unfortunate but this is how things are at the moment. The external application whose functionality I have to incorporate into a WO app has been written with Hybernate and raw JDBC. A main part is the collection of product records according to some rather extensive business rules. For "easy" customization they have resorted to hard code tons of complex select queries just not in the code but in some externally editable form. I'll eventually replace those by proper EOQualifiers and some steering params. But as things are the customer ordered this yesterday with the "urgent wish" to have it ready by last week. :-))))
Just in case you WOndered why.... > On 25.09.2015, at 17:57, Ramsey Gurley <[email protected]> wrote: > > Look out for little Bobby Tables > > https://xkcd.com/327/ <https://xkcd.com/327/> > > ;-) > > On Sep 25, 2015, at 2:26 AM, Markus Ruggiero <[email protected]> > wrote: > >> Thanks for all your help. Here is the code I am using now (might need some >> more error checking) >> >> Wish you all a WOnder-full day >> ---markus--- >> >> public NSArray<Product> findProducts(EOEditingContext ec, String query, >> NSArray<String> queryParameters) { >> >> String resolvedQuery = query; >> for (String aParameter : queryParameters) { >> resolvedQuery = query.replaceFirst( "\\? <smb://?>", >> aParameter ); >> } >> >> EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, >> Product.ENTITY_NAME); >> String modelName = entity.model().name(); >> NSArray<NSDictionary> rows = EOUtilities.rawRowsForSQL( ec, >> modelName, resolvedQuery, null ); >> >> NSMutableArray<String> productCodes = new >> NSMutableArray<String>(); >> for (NSDictionary dict : rows) { >> NSArray<String> values = dict.allValues(); // there is >> only one value in the dict, but we get an Array >> String productCode = values.objectAtIndex( 0 ); >> if (productCode != null) { >> productCodes.addObject( productCode ); >> } >> } >> >> EOQualifier qualifier = >> Product.ATTRIBUTE_PRODUCT_CODE_ERXKEY.in( productCodes ); >> NSArray<Product> results = Product.fetchProducts( ec, >> qualifier, null ); >> return results; >> } >> >> // Example query: >> SELECT prod.PRODUCT_CODE FROM PRODUCT prod, SITE site, INDUSTRY_PRODUCT >> ipr, INDUSTRY ind WHERE prod.SITE_ID = site.ID AND site.SITE_NAME = '?' AND >> ipr.PRODUCT_ID = prod.ID AND ipr.INDUSTRY_ID = ind.ID AND ind.INDUSTRY_NAME >> ='ANH' AND prod.PUB_TRIGGER = 'Y' AND ((prod.EXPIRATION_DATE > SYSDATE) OR >> (prod.EXPIRATION_DATE IS NULL)); >> >> Some are a lot more complex with inner and outer joins and embedded SELECT >> FROM ... WHERE .... IN .... >> >> >> >>> On 24.09.2015, at 16:22, Markus Ruggiero <[email protected] >>> <mailto:[email protected]>> wrote: >>> >>> Folks, >>> >>> What is the preferred way to fetch EOs when you have a db vendor specific >>> "select id from ... where ....." statement? >>> >>> I need to interface with a legacy system where I have to incorporate the >>> functionality of an external java tool into a Wonder app. This external >>> tool executes raw SQL select statements which it reads from a file. All the >>> statements are in the form given above and return a list of primary key >>> values (single column fortunately). The tool then iterates through that >>> list and does whatever it has to do (issuing tons of more raw sql). My >>> problem is that these select statements are rather complex and there are >>> many of them. It is just not feasible to replace those with proper >>> EOQualifiers. In addition these statements are parameterized with ? so they >>> can be precompiled and then used with different query values. However >>> everything can be done with standard EOs as soon as I have those >>> corresponding to the returned list of ids. >>> >>> Thanks a lot >>> ---markus--- >>> _______________________________________________ >>> Do not post admin requests to the list. They will be ignored. >>> Webobjects-dev mailing list ([email protected] >>> <mailto:[email protected]>) >>> Help/Unsubscribe/Update your Subscription: >>> https://lists.apple.com/mailman/options/webobjects-dev/mailinglists%40kataputt.com >>> >>> <https://lists.apple.com/mailman/options/webobjects-dev/mailinglists%40kataputt.com> >>> >>> This email sent to [email protected] >>> <mailto:[email protected]> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list ([email protected] >> <mailto:[email protected]>) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com >> >> <https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com> >> >> This email sent to [email protected] <mailto:[email protected]>
_______________________________________________ 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]
