cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: generics and ObjectContext
Date Tue, 20 Nov 2007 19:22:06 GMT

On Nov 20, 2007, at 9:11 PM, Andrus Adamchik wrote:

>> I think you'll run into issues with a few other queries as well,  
>> such as
>> NamedQuery and ObjectIdQuery.  I guess you could require a new class
>> parameter for them, but it wouldn't be backward compatible.   
>> Likewise, you
>> could force a cast if they're used anonymously, but it's the same  
>> problem
>> you're trying to fix, just in a different place.
> I guess any query that does not take a class (SelectQuery may also  
> be entity-name based) would be Query<?>, resulting in List<?>  
> returned.

Since I am still not fluent with generics, I may have made a wrong  
assumption here. Actually you can do this:

     NamedQuery<Artist> q = new NamedQuery<Artist>("X");
     List<Artist> l = context.performQuery(q);

This won't provide any extra type safety of course, only an  
indication of the result type.


View raw message