cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <>
Subject Re: Fetching a list of objects from a list of primary keys
Date Wed, 14 Sep 2016 21:01:07 GMT
You can use ExpressionFactory.matchDbExp("pk1",
val1).and(ExpressionFactory.matchDbExp("pk2", val2))

Then assemble the resulting AND expressions into a list of OR expressions
using ExpressionFactory.or()

       pk1 = val1 AND pk2 = val2
OR  pk1 = val3 AND pk2 = val4
OR  pk1 = val5 AND pk2 = val6

On Wed, Sep 14, 2016 at 3:41 PM Oksana Peterburgskaya <> wrote:

> Hello,
> I'm currently working on  a case related to this post where I try to fetch
> a list of objects based on a list of primary keys. The difference for me is
> that the primary key consists of multiple fields id db. If I try to use
> ObjectForPK(), it accepts such multi-park PKs. However, if I try to put
> multiple multip-part PK in input maps for ObjectForPK(), ObjectForPK() but
> only returns the first object, not all of them.
> I can't really user ExpressionFactory.InDBExp() the way it is suggested in
> the post. Are there any other solutions? I really need to do get all
> objects in one query otherwise we are hit with db-related performance
> issues.
> Thank you very much,
> Oksana Peterburgskaya
> Confidentiality Notice: This e-mail and accompanying documents contain
> confidential information intended for a specific individual and purpose.
> This e-mailed information is private and protected by law. If you are not
> the intended recipient, you are hereby notified that any disclosure,
> copying, or distribution, or the taking of any action based on the contents
> of this information, is strictly prohibited.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message