Re: generics and ObjectContext

From: Andrus Adamchik (
Date: Tue Nov 20 2007 - 14:22:06 EST

  • Next message: Andrus Adamchik: "Re: generics and ObjectContext"

    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.


    This archive was generated by hypermail 2.0.0 : Tue Nov 20 2007 - 14:22:39 EST