Mixing expressions and raw SQL in Cayenne 4.0B2

2018-03-19 Thread Ken Anderson
All, We’d like to be able to select records from a table where we use an Expression in a SelectQuery for most attributes, but then we want to limit the query to an IN or EXISTS qualifier as well. We’d rather not bring all the objects back just so we can do the query, so we’d like to add someth

Re: Fetching a to-many DbRelationship

2018-03-19 Thread dollj
Sorry that was maybe a bit cryptic, here's working code (from Cay 3.1.1) as per your imaginary case: class Company extends _Company { public List getEmployees() { ObjRelationship rel = (ObjRelationship) Cayenne.getObjEntity( getObjectContext().newObject( Emloyee.class ) )

Re: Fetching a to-many DbRelationship

2018-03-19 Thread dollj
How about something like: ObjRelationship rel = Cayenne.getObjEntity( employee ).getAnyRelationship( company ).getReverseRelationship(); Jurgen -Original Message- From: Maik Musall Sent: Monday, March 19, 2018 3:41 PM To: user@cayenne.apache.org Subject: Re: Fetching a to-many DbRe

Re: Fetching a to-many DbRelationship

2018-03-19 Thread Maik Musall
I have cases of this like a reference to the user that created an object. Over the years, those become millions of objects, so if the application would somehow stumble upon the back-relationship and try to resolve 1:n with millions of objects, it would stall for a while, crossing the threshold t

Re: Fetching a to-many DbRelationship

2018-03-19 Thread Michael Gentry
I wouldn't think having company->>employees modeled would cause a performance issue. Did you try it first and then remove it? On Mon, Mar 19, 2018 at 8:39 AM, Hugi Thordarson wrote: > No, I only have a DbRelationship so no code gets generated. The > ObjRelationship is only modeled in one direc

Re: Fetching a to-many DbRelationship

2018-03-19 Thread Hugi Thordarson
No, I only have a DbRelationship so no code gets generated. The ObjRelationship is only modeled in one direction for performance reasons. Imagine a relationship Company <->> Employees where both DbRelationships are modeled but only "Emploee" has a "company" relationship, "Company" has no "e

Re: Fetching a to-many DbRelationship

2018-03-19 Thread Michael Gentry
Hi Hugi, Do you mean something like lineItem.getOrders(); ? On Mon, Mar 19, 2018 at 7:06 AM, Hugi Thordarson wrote: > Hi all, > I feel like this is something I should know so I'm almost hesitant to ask. > But… > > I have a DataObject - how do I read the value of a ToMany DbRelationship > it ha

Fetching a to-many DbRelationship

2018-03-19 Thread Hugi Thordarson
Hi all, I feel like this is something I should know so I'm almost hesitant to ask. But… I have a DataObject - how do I read the value of a ToMany DbRelationship it has? Cheers, - hugi