Yeah sorry, I replied too soon :) While you can do 'matchAnyExp' with HOLLOW objects without triggering their resolution, getting a handle of a HOLLOW object may require some code. So 'inDbExp' is the solution in this case.
Andrus On Apr 3, 2012, at 7:32 PM, Ramiro Aparicio wrote: > As I see it that will indeed use a query per user to create the expression, > as every objectForPk will need one query to at least determine if the user > exist or not and retrieve the user object, wich is just what I was trying to > avoid. > > > El 03/04/2012 18:21, Andrus Adamchik escribió: >> Actually here is a more terse syntax: >> >> User u2 = Cayenne.objectForPk(context, User.class, 2); >> User u5 = Cayenne.objectForPk(context, User.class, 5); >> >> Expression e = ExpressionFactory.matchAnyExp(u2, u5); >> >> >> On Apr 3, 2012, at 7:19 PM, Andrus Adamchik wrote: >> >>> Don't forget that Cayenne analog of matching against a PK in DB is matching >>> against the Object itself! >>> >>> User u2 = Cayenne.objectForPk(context, User.class, 2); >>> User u5 = Cayenne.objectForPk(context, User.class, 5); >>> >>> Expression e2 = ExpressionFactory.matchExp(u2); >>> Expression e5 = ExpressionFactory.matchExp(u5); >>> >>> Expression e = e2.orExp(e5); >>> >>> Andrus >>> >>> >>> On Apr 3, 2012, at 6:43 PM, Michael Gentry wrote: >>> >>>> Hi Ramiro, >>>> >>>> By default, Cayenne does not map PKs into Java objects because they >>>> are considered database artifacts. >>>> >>>> What is the source of your idUser values (the 2,5)? If external to >>>> your application, you can always manually add idUser back into your >>>> ObjEntity in Cayenne Modeler. >>>> >>>> If the source is really internal, you might want to consider matching >>>> against user names or objects or other attributes. >>>> >>>> mrg >>>> >>>> >>>> On Tue, Apr 3, 2012 at 11:18 AM, Ramiro Aparicio >>>> <ramiro.apari...@prot-on.com> wrote: >>>>> I am trying to do what I thought it should be an easy query >>>>> >>>>> SELECT * FROM Users WHERE idUser IN (2,5) >>>>> >>>>> The problem is that it seems that the primary key of tables is somewhat >>>>> of a >>>>> special column that is not allowed to be used in expressions as I get >>>>> Can't resolve path component: [User.idUser]. >>>>> >>>>> My current piece of code is: >>>>> >>>>> Expression where = ExpressionFactory.inExp(ID_USER_PK_COLUMN, userids); >>>>> SelectQuery query = new SelectQuery(User.class, where); >>>>> @SuppressWarnings("unchecked") >>>>> List<User> dbUsers = dataContext.performQuery(query); >>>>> >>>>> I know I can use objectForPK for every id but that doesn't seem to be too >>>>> sensible, so can anyone please point me another way to get the user list >>>>> in >>>>> just 1 query? >>>>> >>>>> Thanks in advance >>>>> Ramiro >>> >> > >