Re: Query using foreign objects

From: Mike Kienenberger (mkienen..mail.com)
Date: Tue Feb 07 2006 - 12:09:30 EST

  • Next message: Andrus Adamchik: "Re: Query using foreign objects"

    Dave, I didn't answer earlier because I'm back in the stone age
    manually building expressions. But maybe you're doing the same
    thing.

    Is this the sort of thing you're looking for?

    ExpressionFactory.matchDbExp(EngWork.ENG_WORK_ID_PK_COLUMN, workNumber)

    On 2/7/06, Dave Merrin <dmerri..pasystems.co.uk> wrote:
    > Hi Andrus,
    >
    > How does your function help me create an expression using several primary
    > keys?
    >
    > Expression exp1 = ExpressionFactory.matchExp(ItemType.ITEM_TYPE_ID_PK, 1);
    > Expression exp2 =
    > ExpressionFactory.matchExp(ItemProperty.ITEM_PROPERTY_ID_PK, 2);
    > Expression exp = exp1.andExp(exp2);
    >
    > SelectQuery query = new SelectQuery(Item.class, exp);
    > List<Item> list = dataContext.performQuery(query);
    >
    > The above won't work unless I map an ObjEntity to the DbEntity for the
    > primary key.
    >
    > Dave
    >
    >
    > > -----Original Message-----
    > > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > > Sent: 07 February 2006 16:25
    > > To: cayenne-use..bjectstyle.org
    > > Subject: Re: Query using foreign objects
    > >
    > >
    > >
    > > On Feb 7, 2006, at 11:20 AM, Dave Merrin wrote:
    > >
    > > > This is not for retrieving the primary key. It is for using the
    > > > primary key
    > > > in an expression.
    > >
    > > You can create a getter - it should work in expressions:
    > >
    > > public Object getId() {
    > > if(getpersistenceState == PersistenceState.NEW) {
    > > return null;
    > > }
    > > else {
    > > return pkForObject(this);
    > > }
    > > }
    > >
    > > Andrus
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Feb 07 2006 - 12:09:32 EST