On Dec 21, 2007, at 2:30 PM, Tore Halset wrote:

The more I think about it, the more I feel like we'll have to do some kind of Context/Query wrapper that supports generics specifically for select queries, similar to what was suggested here:

https://issues.apache.org/cayenne/browse/CAY-877

A wrapper is fine, but do you think this is fixable in Query as well?

Regardless of what I said elsewhere on the topic (the ideas I am still planning to pursue), current version of performQuery is soooo painful to use. We MUST do something about it. Here is one idea - revert generics version of "performQuery":

--- framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/ cayenne/ObjectContext.java (revision 606412) +++ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/ cayenne/ObjectContext.java (working copy)
@@ -156,7 +156,8 @@
    /**
* Executes a selecting query, returning a list of persistent objects or data rows.
     */
-    List<?> performQuery(Query query);
+    @SuppressWarnings("unchecked")
+    List performQuery(Query query);


This would at least allow users to assign results without warnings:

  List<Artist> x = context.performQuery(q);

So while there's no added type-safety, at least such API won't result in a downgrade in functionality.

Comments?

Andrus

Reply via email to