Re: to-many relationship where I don't want most of the items

Michael Gentry <[email protected]> Sun, 21 Jun 2026 18:23:26 -0400
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAOy5kzNKfLMMoijqnaTjftJ3O1c=s3TdNsokXM0ag-voG826Eg@mail.gmail.com>
--000000000000a5b29c0654cafbc5
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

OK, I'll send it shortly. (After I eat dinner.)

On Sun, Jun 21, 2026 at 6:13=E2=80=AFPM Robert A. Decker <decker@robdecker.=
com>
wrote:

> Yes that'd be great. I'll see if I can get it working in 4.x. It sounds
> like what  was going to start looking into.
>
> Rob
>
> Sent from my iPhone
>
> > On Jun 21, 2026, at 23:58, Michael Gentry <[email protected]> wrote:
> >
> > =EF=BB=BFI have a CayenneUtils from a 3.1 project I could send you. Not=
 sure if
> it
> > would work with your version of Cayenne, but it includes methods such a=
s:
> >
> > - boolean isDirty(DataContext dataContext) // Checks if there are
> modified
> > objects in the DC, ignoring phantoms.
> >
> > - Collection<? extends CayenneDataObject> newObjects(DataContext
> > dataContext) // Returns all new objects in the DC.
> >
> > - Collection<? extends CayenneDataObject> deletedObjects(DataContext
> > dataContext) // Returns all deleted objects in the DC.
> >
> > - Collection<? extends CayenneDataObject> modifiedObjects(DataContext
> > dataContext) // Returns all modified objects in the DC.
> >
> > - Collection<? extends CayenneDataObject> uncommittedObjects(DataContex=
t
> > dataContext) // Returns all uncommitted objects in the DC.
> >
> > - <T> Collection<T> objectsForType(Collection<? extends
> CayenneDataObject>
> > searchObjects, Class<T> type) // Looks for objects of a certain type.
> >
> >
> > You could do an objectsForType(newObjects(dc), DataMarkerEntry.class) t=
o
> > find your non-persisted DataMarkerEntry entries. And then maybe pair
> those
> > objects with your visibleDataMarkerEntries().
> >
> >
> >> On Sun, Jun 21, 2026 at 5:39=E2=80=AFPM Robert A. Decker <decker@robde=
cker.com>
> >> wrote:
> >>
> >> Yes I added them to the relationship - I just assume that if I iterate
> >> through the data markers on the relationship including the new ones
> it'll
> >> hit the database a bunch, loading in the faults as I look for
> isVisible=3Dtrue
> >>
> >> I'm porting this from WebObjects and looking at the old code they pass=
ed
> >> the new data markers in and added them to the return list pulled from
> the
> >> database.
> >>
> >> I was wondering if there's a way to get, for example, non-persisted
> >> entries of a certain type. I'll look at the api.
> >>
> >> If I have to I'll just pull them all out of the database and filter
> them.
> >> There's only a small number of users with hundreds of data markers -
> most
> >> people only have a few.
> >>
> >> Rob
> >>
> >> Sent from my iPhone
> >>
> >>>> On Jun 21, 2026, at 23:26, Michael Gentry <[email protected]>
> wrote:
> >>>
> >>> =EF=BB=BFHi Robert,
> >>>
> >>> Just curious where your non-persisted DataMarkerEntry objects are lyi=
ng
> >>> around. I'm assuming you haven't added them to your dataMarkerEntries
> >>> relationship yet.
> >>>
> >>> Thanks,
> >>> mrg
> >>>
> >>>
> >>>> On Sun, Jun 21, 2026 at 11:25=E2=80=AFAM Robert A. Decker <
> [email protected]
> >>>
> >>>> wrote:
> >>>>
> >>>> I have a to-many relationship where I really only want to pull out a
> few
> >>>> out of hundreds. In this case, it's those with is_visible set to
> true. I
> >>>> never actually work with them when is_visible is false, but I can't
> >> delete
> >>>> them either because they audit changes.
> >>>>
> >>>> person.dataMarkerEntries - this is modelled in the modeller and pull=
s
> >> all
> >>>> data marker entries from the database. I don't want this.
> >>>> person.visibleDataMarkerEntries  - this is my method and it has a
> query
> >>>> that only pulls out visible data marker entries from the database:
> >>>>
> >>>> ObjectSelect<DataMarkerEntry> query =3D
> >>>> ObjectSelect.query(DataMarkerEntry.class)
> >>>> .where(DataMarkerEntry.IS_VISIBLE.isTrue())
> >>>> ....
> >>>>
> >>>> However, the visibleDataMarkerEntries won't include non-persisted
> (new)
> >>>> data marker entries. But if I call dataMarkerEntries to see the
> >>>> non-persisted data marker entries then will it pull all of them out =
of
> >> the
> >>>> database too?
> >>>>
> >>>> Is there a way for me in visibleDataMarkerEntries to also include
> >>>> non-persisted data marker entries off of my personr instance?
> >>>>
> >>>> Rob
> >>>>
> >>>>
> >>
>

--000000000000a5b29c0654cafbc5--