Re: API wish(es)

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Mon Apr 06 2009 - 07:51:46 EDT

  • Next message: Michael Gentry: "Re: Quick query question"

    The correct way to get fresh object is similiar to the method in
    DataObjectUtils:

    public static Object freshObjectForPK(ObjectContext context, ObjectId id) {
            return DataObjectUtils.objectForQuery(context, new ObjectIdQuery(
                    id,
                    false,
                    ObjectIdQuery.REFRESH));
        }

    BTW right here's a method which returns one object of query result

    2009/4/6 Borut Bolina <borut.bolcin..mail.com>

    > Hi,
    >
    > would it be possible to add one method in DataObjectUtils,
    >
    > DataObjectA dataObjectA = DataObjectUtils.objectForPK(dataContext,
    > DataObjectA.class, 1, QueryCacheStrategy.NO_CACHE);
    >
    > which would always return a fresh object.
    >
    >
    > By the way, is this the correct way of fetching an object directly
    > from database?
    >
    > Expression e = ExpressionFactory.matchExp(DataObjectA.ID_PK_COLUMN, "1");
    > SelectQuery query = new SelectQuery(DataObjectA.class, e);
    > query.setCacheStrategy(QueryCacheStrategy.NO_CACHE);
    > List list = dataContext.performQuery(query);
    >
    > DataObjectA objectA= null;
    > if (list.size() > 0) {
    > objectA= (DataObjectA) list.get(0);
    > }
    >
    > The above code would still use object cache, right, so I will not be
    > getting the object with values as set in database (maybe changed by
    > 3rd party process). How to overcome this in the above code?
    >
    > Also, wouldn't it be convenient if performQuery could return just one
    > object so we do not have to always type the boilerplate
    > if(list.size>0) ?
    >
    > Regards,
    > Borut
    >



    This archive was generated by hypermail 2.0.0 : Mon Apr 06 2009 - 07:52:21 EDT