cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ramiro Aparicio <ramiro.apari...@prot-on.com>
Subject Using primary keys in expressions
Date Tue, 03 Apr 2012 15:18:56 GMT
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

Mime
View raw message