cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: 3.2M1 first impressions
Date Mon, 11 Nov 2013 18:06:43 GMT
Hi,

Thanks for the feedback! Good to have that for 3.2.

>  all the generics code uses just T as "T extends Object" and not "T extends DataObject"
(or maybe another superinterface wich makes sense) 

Some of it is because query result can be a DataRow, or an Object[]. Other places (like “deleteObjects”)
should indeed be changed to something like T extends Peristent. Agreed.

> Also I miss a generics typed version of objectForQuery I did it for myself so maybe you
can include it in the next version:

This API continues to evolve on trunk. E.g. we don’t have Cayenne.objectForSelect, but there’s
a better method now - ObjectContext.selectOne(..) :

http://svn.apache.org/repos/asf/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java

Further comments are certainly welcomed.

Andrus

On Nov 11, 2013, at 8:48 PM, Ramiro Aparicio <ramiro.aparicio@prot-on.com> wrote:

> Hi,
> 
> I am doing today my usual updated maven depencies for our future product release, so
I am migrating my 3.1 code to the new 3.2 generics style and I missed that  all the generics
code uses just T as "T extends Object" and not "T extends DataObject" (or maybe another superinterface
wich makes sense) it is not a serious issue but it can help avoiding runtime errors if you
miss the correct class name.
> 
> Also I miss a generics typed version of objectForQuery I did it for myself so maybe you
can include it in the next version:
> 
> // Must add context as parameter
>    protected <U extends DataObject, T extends Select<U>> U objectForQuery
(T query) {
>        List<U> objects = getThreadDataContext().select(query);
> 
>        if (objects.size() == 0) {
>            return null;
>        } else if (objects.size() > 1) {
>            throw new CayenneRuntimeException("Expected zero or one object, instead query
matched: " + objects.size());
>        }
> 
>        return objects.get(0);
>    }
> 
> I will tell you if I find something worth noting.
> 
> Best regards.
> 
> Ramiro Aparicio
> 


Mime
View raw message