cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: Using primary keys in expressions
Date Tue, 03 Apr 2012 15:43:38 GMT
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.


On Tue, Apr 3, 2012 at 11:18 AM, Ramiro Aparicio
<> 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

View raw message