Hi, For raw row fetches, there is a shorter way:
EOEditingContext ec = ERXEC.newEditingContext(); NSArray<NSDictionary> rawRows = EOUtilities.rawRowsForSQL(ec, "YourModelName", sql)); ... Samuel > Le 2015-09-24 à 14:48, Johann Werner <j...@oyosys.com> a écrit : > > Hi Markus, > > I did not clearly understand what you are exactly trying to achieve. If you > just need to run the vendor specific SQL to get a list of primary keys that > you can then use to fetch the EOs you want you could do something like > > > EOEditingContext ec = ERXEC.newEditingContext(); > EOEntity entity = ERXEOAccessUtilities.entityNamed(MyEntity.ENTITY_NAME); > EODatabaseContext context = > EODatabaseContext.registeredDatabaseContextForModel(entity.model(), ec); > EOSQLExpressionFactory factory = > context.database().adaptor().expressionFactory(); > EOSQLExpression expression = factory.expressionForString("SELECT …"); > NSArray<NSDictionary> rawRows = > ERXEOAccessUtilities.rawRowsForSQLExpression(ec, entity.model().name(), > expression); > NSArray<Integer> idList = rawRows.valueForKey("id“); > NSArray<MyEntity> result = MyEntity.fetchMyEntities(ec, ERXQ.in("id", > idList), null); > > > Otherwise if you need more than that and need to fetch EOs but have to use > your own SQL instead of the generated one by EOF you probably can do this by > using the hints dictionary of a fetch specification. Something like > > > EOEditingContext ec = ERXEC.newEditingContext(); > ERXFetchSpecification<MyEntity> fs = new > ERXFetchSpecification<>(MyEntity.ENTITY_NAME); > NSDictionary<String, String> hints = new NSDictionary<>("SELECT …" , > EODatabaseContext.CustomQueryExpressionHintKey); > fs.setHints(hints); > NSArray<MyEntity> result = fs.fetchObjects(ec); > > > Though I never used that sort of logic but you could experiment with that. > All code above is written by peeking at the API documentation with extremely > wild guesses included—so no guarantees that it is correct or complete. Use at > your own risk ;-) > > jw > > >> Am 24.09.2015 um 16:22 schrieb Markus Ruggiero <mailingli...@kataputt.com>: >> >> 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 (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com > > This email sent to sam...@samkar.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com